diff --git a/sdk/sql/azure-mgmt-sql/_meta.json b/sdk/sql/azure-mgmt-sql/_meta.json index 05f1d1129912b..179460cccca23 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "16d746c3411d553df56df7bedbcef0682115ad18", + "commit": "ef755b98ac0b4c3de1c3b40a1af29bd0805b22c4", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/sql/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/sql/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/sql/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py index b8c8ee7ad0955..2f06a5a5063c3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SqlManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py index c6bef90d0627d..5635a04df0ebc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class SqlManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(SqlManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(SqlManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json index a9e8e820118c0..3b7bc2bfe73fb 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json @@ -1,17 +1,17 @@ { "chosen_version": "", - "total_api_version_list": ["2014-04-01", "2020-11-01-preview", "2021-02-01-preview", "2021-05-01-preview"], + "total_api_version_list": ["2014-04-01", "2020-11-01-preview", "2021-02-01-preview", "2021-05-01-preview", "2021-08-01-preview"], "client": { "name": "SqlManagementClient", "filename": "_sql_management_client", "description": "The Azure SQL Database management API provides a RESTful set of web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete databases.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SqlManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SqlManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SqlManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SqlManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "recoverable_databases": "RecoverableDatabasesOperations", @@ -173,7 +172,6 @@ "managed_restorable_dropped_database_backup_short_term_retention_policies": "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations", "managed_server_security_alert_policies": "ManagedServerSecurityAlertPoliciesOperations", "operations": "Operations", - "operations_health": "OperationsHealthOperations", "private_endpoint_connections": "PrivateEndpointConnectionsOperations", "private_link_resources": "PrivateLinkResourcesOperations", "recoverable_managed_databases": "RecoverableManagedDatabasesOperations", @@ -216,6 +214,7 @@ "managed_instances": "ManagedInstancesOperations", "restorable_dropped_databases": "RestorableDroppedDatabasesOperations", "restorable_dropped_managed_databases": "RestorableDroppedManagedDatabasesOperations", - "server_connection_policies": "ServerConnectionPoliciesOperations" + "server_connection_policies": "ServerConnectionPoliciesOperations", + "ipv6_firewall_rules": "IPv6FirewallRulesOperations" } } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_patch.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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 005af492b32c0..3e0a8bb608112 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 @@ -6,142 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SqlManagementClientConfiguration +from .operations import BackupShortTermRetentionPoliciesOperations, CapabilitiesOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, DataWarehouseUserActivitiesOperations, DatabaseAdvisorsOperations, DatabaseAutomaticTuningOperations, DatabaseBlobAuditingPoliciesOperations, DatabaseColumnsOperations, DatabaseExtensionsOperations, DatabaseOperationsOperations, DatabaseRecommendedActionsOperations, DatabaseSchemasOperations, DatabaseSecurityAlertPoliciesOperations, DatabaseTablesOperations, DatabaseUsagesOperations, DatabaseVulnerabilityAssessmentRuleBaselinesOperations, DatabaseVulnerabilityAssessmentScansOperations, DatabaseVulnerabilityAssessmentsOperations, DatabasesOperations, DeletedServersOperations, ElasticPoolActivitiesOperations, ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, 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, ManagedServerSecurityAlertPoliciesOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RecommendedSensitivityLabelsOperations, RecoverableDatabasesOperations, RecoverableManagedDatabasesOperations, ReplicationLinksOperations, RestorableDroppedDatabasesOperations, RestorableDroppedManagedDatabasesOperations, RestorePointsOperations, SensitivityLabelsOperations, ServerAdvisorsOperations, ServerAutomaticTuningOperations, ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, ServerCommunicationLinksOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, ServerDnsAliasesOperations, ServerKeysOperations, ServerOperationsOperations, ServerSecurityAlertPoliciesOperations, 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 - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import SqlManagementClientConfiguration -from .operations import RecoverableDatabasesOperations -from .operations import DataMaskingPoliciesOperations -from .operations import DataMaskingRulesOperations -from .operations import GeoBackupPoliciesOperations -from .operations import DatabasesOperations -from .operations import ElasticPoolsOperations -from .operations import ReplicationLinksOperations -from .operations import ServerCommunicationLinksOperations -from .operations import ServiceObjectivesOperations -from .operations import ElasticPoolActivitiesOperations -from .operations import ElasticPoolDatabaseActivitiesOperations -from .operations import ServerUsagesOperations -from .operations import ExtendedDatabaseBlobAuditingPoliciesOperations -from .operations import ExtendedServerBlobAuditingPoliciesOperations -from .operations import ServerBlobAuditingPoliciesOperations -from .operations import DatabaseBlobAuditingPoliciesOperations -from .operations import DatabaseAdvisorsOperations -from .operations import DatabaseAutomaticTuningOperations -from .operations import DatabaseColumnsOperations -from .operations import DatabaseRecommendedActionsOperations -from .operations import DatabaseSchemasOperations -from .operations import DatabaseSecurityAlertPoliciesOperations -from .operations import DatabaseTablesOperations -from .operations import DatabaseVulnerabilityAssessmentRuleBaselinesOperations -from .operations import DatabaseVulnerabilityAssessmentsOperations -from .operations import DatabaseVulnerabilityAssessmentScansOperations -from .operations import DataWarehouseUserActivitiesOperations -from .operations import DeletedServersOperations -from .operations import ElasticPoolOperationsOperations -from .operations import EncryptionProtectorsOperations -from .operations import FailoverGroupsOperations -from .operations import FirewallRulesOperations -from .operations import InstanceFailoverGroupsOperations -from .operations import InstancePoolsOperations -from .operations import JobAgentsOperations -from .operations import JobCredentialsOperations -from .operations import JobExecutionsOperations -from .operations import JobsOperations -from .operations import JobStepExecutionsOperations -from .operations import JobStepsOperations -from .operations import JobTargetExecutionsOperations -from .operations import JobTargetGroupsOperations -from .operations import JobVersionsOperations -from .operations import CapabilitiesOperations -from .operations import LongTermRetentionPoliciesOperations -from .operations import MaintenanceWindowOptionsOperations -from .operations import MaintenanceWindowsOperations -from .operations import ManagedBackupShortTermRetentionPoliciesOperations -from .operations import ManagedDatabaseColumnsOperations -from .operations import ManagedDatabaseQueriesOperations -from .operations import ManagedDatabaseRestoreDetailsOperations -from .operations import ManagedDatabasesOperations -from .operations import ManagedDatabaseSchemasOperations -from .operations import ManagedDatabaseSecurityAlertPoliciesOperations -from .operations import ManagedDatabaseSecurityEventsOperations -from .operations import ManagedDatabaseSensitivityLabelsOperations -from .operations import ManagedDatabaseRecommendedSensitivityLabelsOperations -from .operations import ManagedDatabaseTablesOperations -from .operations import ManagedDatabaseTransparentDataEncryptionOperations -from .operations import ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations -from .operations import ManagedDatabaseVulnerabilityAssessmentsOperations -from .operations import ManagedDatabaseVulnerabilityAssessmentScansOperations -from .operations import ManagedInstanceAdministratorsOperations -from .operations import ManagedInstanceAzureADOnlyAuthenticationsOperations -from .operations import ManagedInstanceEncryptionProtectorsOperations -from .operations import ManagedInstanceKeysOperations -from .operations import ManagedInstanceLongTermRetentionPoliciesOperations -from .operations import ManagedInstanceOperationsOperations -from .operations import ManagedInstancePrivateEndpointConnectionsOperations -from .operations import ManagedInstancePrivateLinkResourcesOperations -from .operations import ManagedInstanceTdeCertificatesOperations -from .operations import ManagedInstanceVulnerabilityAssessmentsOperations -from .operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations -from .operations import ManagedServerSecurityAlertPoliciesOperations -from .operations import Operations -from .operations import OperationsHealthOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import RecoverableManagedDatabasesOperations -from .operations import RestorePointsOperations -from .operations import SensitivityLabelsOperations -from .operations import RecommendedSensitivityLabelsOperations -from .operations import ServerAdvisorsOperations -from .operations import ServerAutomaticTuningOperations -from .operations import ServerAzureADAdministratorsOperations -from .operations import ServerAzureADOnlyAuthenticationsOperations -from .operations import ServerDevOpsAuditSettingsOperations -from .operations import ServerDnsAliasesOperations -from .operations import ServerKeysOperations -from .operations import ServerOperationsOperations -from .operations import ServerSecurityAlertPoliciesOperations -from .operations import ServerTrustGroupsOperations -from .operations import ServerVulnerabilityAssessmentsOperations -from .operations import SqlAgentOperations -from .operations import SubscriptionUsagesOperations -from .operations import SyncAgentsOperations -from .operations import SyncGroupsOperations -from .operations import SyncMembersOperations -from .operations import TdeCertificatesOperations -from .operations import TimeZonesOperations -from .operations import VirtualClustersOperations -from .operations import VirtualNetworkRulesOperations -from .operations import WorkloadClassifiersOperations -from .operations import WorkloadGroupsOperations -from .operations import TransparentDataEncryptionsOperations -from .operations import BackupShortTermRetentionPoliciesOperations -from .operations import DatabaseExtensionsOperations -from .operations import DatabaseOperationsOperations -from .operations import DatabaseUsagesOperations -from .operations import LedgerDigestUploadsOperations -from .operations import OutboundFirewallRulesOperations -from .operations import ServersOperations -from .operations import UsagesOperations -from .operations import LongTermRetentionBackupsOperations -from .operations import LongTermRetentionManagedInstanceBackupsOperations -from .operations import ManagedInstancesOperations -from .operations import RestorableDroppedDatabasesOperations -from .operations import RestorableDroppedManagedDatabasesOperations -from .operations import ServerConnectionPoliciesOperations -from . import models - -class SqlManagementClient(object): +class SqlManagementClient: """The Azure SQL Database management API provides a RESTful set of web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete databases. :ivar recoverable_databases: RecoverableDatabasesOperations operations @@ -159,23 +39,31 @@ class SqlManagementClient(object): :ivar replication_links: ReplicationLinksOperations operations :vartype replication_links: azure.mgmt.sql.operations.ReplicationLinksOperations :ivar server_communication_links: ServerCommunicationLinksOperations operations - :vartype server_communication_links: azure.mgmt.sql.operations.ServerCommunicationLinksOperations + :vartype server_communication_links: + azure.mgmt.sql.operations.ServerCommunicationLinksOperations :ivar service_objectives: ServiceObjectivesOperations operations :vartype service_objectives: azure.mgmt.sql.operations.ServiceObjectivesOperations :ivar elastic_pool_activities: ElasticPoolActivitiesOperations operations :vartype elastic_pool_activities: azure.mgmt.sql.operations.ElasticPoolActivitiesOperations :ivar elastic_pool_database_activities: ElasticPoolDatabaseActivitiesOperations operations - :vartype elastic_pool_database_activities: azure.mgmt.sql.operations.ElasticPoolDatabaseActivitiesOperations + :vartype elastic_pool_database_activities: + azure.mgmt.sql.operations.ElasticPoolDatabaseActivitiesOperations :ivar server_usages: ServerUsagesOperations operations :vartype server_usages: azure.mgmt.sql.operations.ServerUsagesOperations - :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations operations - :vartype extended_database_blob_auditing_policies: azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations - :ivar extended_server_blob_auditing_policies: ExtendedServerBlobAuditingPoliciesOperations operations - :vartype extended_server_blob_auditing_policies: azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations + :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations + operations + :vartype extended_database_blob_auditing_policies: + azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations + :ivar extended_server_blob_auditing_policies: ExtendedServerBlobAuditingPoliciesOperations + operations + :vartype extended_server_blob_auditing_policies: + azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations - :vartype server_blob_auditing_policies: azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations + :vartype server_blob_auditing_policies: + azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations :ivar database_blob_auditing_policies: DatabaseBlobAuditingPoliciesOperations operations - :vartype database_blob_auditing_policies: azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations + :vartype database_blob_auditing_policies: + azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations :ivar database_advisors: DatabaseAdvisorsOperations operations :vartype database_advisors: azure.mgmt.sql.operations.DatabaseAdvisorsOperations :ivar database_automatic_tuning: DatabaseAutomaticTuningOperations operations @@ -183,21 +71,29 @@ class SqlManagementClient(object): :ivar database_columns: DatabaseColumnsOperations operations :vartype database_columns: azure.mgmt.sql.operations.DatabaseColumnsOperations :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations - :vartype database_recommended_actions: azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations + :vartype database_recommended_actions: + azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations :ivar database_schemas: DatabaseSchemasOperations operations :vartype database_schemas: azure.mgmt.sql.operations.DatabaseSchemasOperations :ivar database_security_alert_policies: DatabaseSecurityAlertPoliciesOperations operations - :vartype database_security_alert_policies: azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations + :vartype database_security_alert_policies: + azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations :ivar database_tables: DatabaseTablesOperations operations :vartype database_tables: azure.mgmt.sql.operations.DatabaseTablesOperations - :ivar database_vulnerability_assessment_rule_baselines: DatabaseVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype database_vulnerability_assessment_rule_baselines: azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations + :ivar database_vulnerability_assessment_rule_baselines: + DatabaseVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype database_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations :ivar database_vulnerability_assessments: DatabaseVulnerabilityAssessmentsOperations operations - :vartype database_vulnerability_assessments: azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations - :ivar database_vulnerability_assessment_scans: DatabaseVulnerabilityAssessmentScansOperations operations - :vartype database_vulnerability_assessment_scans: azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations + :vartype database_vulnerability_assessments: + azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations + :ivar database_vulnerability_assessment_scans: DatabaseVulnerabilityAssessmentScansOperations + operations + :vartype database_vulnerability_assessment_scans: + azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations - :vartype data_warehouse_user_activities: azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations + :vartype data_warehouse_user_activities: + azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations :ivar deleted_servers: DeletedServersOperations operations :vartype deleted_servers: azure.mgmt.sql.operations.DeletedServersOperations :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations @@ -233,91 +129,135 @@ class SqlManagementClient(object): :ivar capabilities: CapabilitiesOperations operations :vartype capabilities: azure.mgmt.sql.operations.CapabilitiesOperations :ivar long_term_retention_policies: LongTermRetentionPoliciesOperations operations - :vartype long_term_retention_policies: azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations + :vartype long_term_retention_policies: + azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations :ivar maintenance_window_options: MaintenanceWindowOptionsOperations operations - :vartype maintenance_window_options: azure.mgmt.sql.operations.MaintenanceWindowOptionsOperations + :vartype maintenance_window_options: + azure.mgmt.sql.operations.MaintenanceWindowOptionsOperations :ivar maintenance_windows: MaintenanceWindowsOperations operations :vartype maintenance_windows: azure.mgmt.sql.operations.MaintenanceWindowsOperations - :ivar managed_backup_short_term_retention_policies: ManagedBackupShortTermRetentionPoliciesOperations operations - :vartype managed_backup_short_term_retention_policies: azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations + :ivar managed_backup_short_term_retention_policies: + ManagedBackupShortTermRetentionPoliciesOperations operations + :vartype managed_backup_short_term_retention_policies: + azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations :vartype managed_database_columns: azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations :ivar managed_database_queries: ManagedDatabaseQueriesOperations operations :vartype managed_database_queries: azure.mgmt.sql.operations.ManagedDatabaseQueriesOperations :ivar managed_database_restore_details: ManagedDatabaseRestoreDetailsOperations operations - :vartype managed_database_restore_details: azure.mgmt.sql.operations.ManagedDatabaseRestoreDetailsOperations + :vartype managed_database_restore_details: + azure.mgmt.sql.operations.ManagedDatabaseRestoreDetailsOperations :ivar managed_databases: ManagedDatabasesOperations operations :vartype managed_databases: azure.mgmt.sql.operations.ManagedDatabasesOperations :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations :vartype managed_database_schemas: azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations - :ivar managed_database_security_alert_policies: ManagedDatabaseSecurityAlertPoliciesOperations operations - :vartype managed_database_security_alert_policies: azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations + :ivar managed_database_security_alert_policies: ManagedDatabaseSecurityAlertPoliciesOperations + operations + :vartype managed_database_security_alert_policies: + azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations :ivar managed_database_security_events: ManagedDatabaseSecurityEventsOperations operations - :vartype managed_database_security_events: azure.mgmt.sql.operations.ManagedDatabaseSecurityEventsOperations - :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations operations - :vartype managed_database_sensitivity_labels: azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations - :ivar managed_database_recommended_sensitivity_labels: ManagedDatabaseRecommendedSensitivityLabelsOperations operations - :vartype managed_database_recommended_sensitivity_labels: azure.mgmt.sql.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations + :vartype managed_database_security_events: + azure.mgmt.sql.operations.ManagedDatabaseSecurityEventsOperations + :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations + operations + :vartype managed_database_sensitivity_labels: + azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations + :ivar managed_database_recommended_sensitivity_labels: + ManagedDatabaseRecommendedSensitivityLabelsOperations operations + :vartype managed_database_recommended_sensitivity_labels: + azure.mgmt.sql.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations :ivar managed_database_tables: ManagedDatabaseTablesOperations operations :vartype managed_database_tables: azure.mgmt.sql.operations.ManagedDatabaseTablesOperations - :ivar managed_database_transparent_data_encryption: ManagedDatabaseTransparentDataEncryptionOperations operations - :vartype managed_database_transparent_data_encryption: azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations - :ivar managed_database_vulnerability_assessment_rule_baselines: ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype managed_database_vulnerability_assessment_rule_baselines: azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations - :ivar managed_database_vulnerability_assessments: ManagedDatabaseVulnerabilityAssessmentsOperations operations - :vartype managed_database_vulnerability_assessments: azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations - :ivar managed_database_vulnerability_assessment_scans: ManagedDatabaseVulnerabilityAssessmentScansOperations operations - :vartype managed_database_vulnerability_assessment_scans: azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations + :ivar managed_database_transparent_data_encryption: + ManagedDatabaseTransparentDataEncryptionOperations operations + :vartype managed_database_transparent_data_encryption: + azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations + :ivar managed_database_vulnerability_assessment_rule_baselines: + ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype managed_database_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations + :ivar managed_database_vulnerability_assessments: + ManagedDatabaseVulnerabilityAssessmentsOperations operations + :vartype managed_database_vulnerability_assessments: + azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations + :ivar managed_database_vulnerability_assessment_scans: + ManagedDatabaseVulnerabilityAssessmentScansOperations operations + :vartype managed_database_vulnerability_assessment_scans: + azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations :ivar managed_instance_administrators: ManagedInstanceAdministratorsOperations operations - :vartype managed_instance_administrators: azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations - :ivar managed_instance_azure_ad_only_authentications: ManagedInstanceAzureADOnlyAuthenticationsOperations operations - :vartype managed_instance_azure_ad_only_authentications: azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations - :ivar managed_instance_encryption_protectors: ManagedInstanceEncryptionProtectorsOperations operations - :vartype managed_instance_encryption_protectors: azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations + :vartype managed_instance_administrators: + azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations + :ivar managed_instance_azure_ad_only_authentications: + ManagedInstanceAzureADOnlyAuthenticationsOperations operations + :vartype managed_instance_azure_ad_only_authentications: + azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations + :ivar managed_instance_encryption_protectors: ManagedInstanceEncryptionProtectorsOperations + operations + :vartype managed_instance_encryption_protectors: + azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations :ivar managed_instance_keys: ManagedInstanceKeysOperations operations :vartype managed_instance_keys: azure.mgmt.sql.operations.ManagedInstanceKeysOperations - :ivar managed_instance_long_term_retention_policies: ManagedInstanceLongTermRetentionPoliciesOperations operations - :vartype managed_instance_long_term_retention_policies: azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations + :ivar managed_instance_long_term_retention_policies: + ManagedInstanceLongTermRetentionPoliciesOperations operations + :vartype managed_instance_long_term_retention_policies: + azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations :ivar managed_instance_operations: ManagedInstanceOperationsOperations operations - :vartype managed_instance_operations: azure.mgmt.sql.operations.ManagedInstanceOperationsOperations - :ivar managed_instance_private_endpoint_connections: ManagedInstancePrivateEndpointConnectionsOperations operations - :vartype managed_instance_private_endpoint_connections: azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations - :ivar managed_instance_private_link_resources: ManagedInstancePrivateLinkResourcesOperations operations - :vartype managed_instance_private_link_resources: azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations + :vartype managed_instance_operations: + azure.mgmt.sql.operations.ManagedInstanceOperationsOperations + :ivar managed_instance_private_endpoint_connections: + ManagedInstancePrivateEndpointConnectionsOperations operations + :vartype managed_instance_private_endpoint_connections: + azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations + :ivar managed_instance_private_link_resources: ManagedInstancePrivateLinkResourcesOperations + operations + :vartype managed_instance_private_link_resources: + azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations :ivar managed_instance_tde_certificates: ManagedInstanceTdeCertificatesOperations operations - :vartype managed_instance_tde_certificates: azure.mgmt.sql.operations.ManagedInstanceTdeCertificatesOperations - :ivar managed_instance_vulnerability_assessments: ManagedInstanceVulnerabilityAssessmentsOperations operations - :vartype managed_instance_vulnerability_assessments: azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations - :ivar managed_restorable_dropped_database_backup_short_term_retention_policies: ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations operations - :vartype managed_restorable_dropped_database_backup_short_term_retention_policies: azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations - :ivar managed_server_security_alert_policies: ManagedServerSecurityAlertPoliciesOperations operations - :vartype managed_server_security_alert_policies: azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations + :vartype managed_instance_tde_certificates: + azure.mgmt.sql.operations.ManagedInstanceTdeCertificatesOperations + :ivar managed_instance_vulnerability_assessments: + ManagedInstanceVulnerabilityAssessmentsOperations operations + :vartype managed_instance_vulnerability_assessments: + azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations + :ivar managed_restorable_dropped_database_backup_short_term_retention_policies: + ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations operations + :vartype managed_restorable_dropped_database_backup_short_term_retention_policies: + azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations + :ivar managed_server_security_alert_policies: ManagedServerSecurityAlertPoliciesOperations + operations + :vartype managed_server_security_alert_policies: + azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.sql.operations.Operations - :ivar operations_health: OperationsHealthOperations operations - :vartype operations_health: azure.mgmt.sql.operations.OperationsHealthOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.sql.operations.PrivateLinkResourcesOperations :ivar recoverable_managed_databases: RecoverableManagedDatabasesOperations operations - :vartype recoverable_managed_databases: azure.mgmt.sql.operations.RecoverableManagedDatabasesOperations + :vartype recoverable_managed_databases: + azure.mgmt.sql.operations.RecoverableManagedDatabasesOperations :ivar restore_points: RestorePointsOperations operations :vartype restore_points: azure.mgmt.sql.operations.RestorePointsOperations :ivar sensitivity_labels: SensitivityLabelsOperations operations :vartype sensitivity_labels: azure.mgmt.sql.operations.SensitivityLabelsOperations :ivar recommended_sensitivity_labels: RecommendedSensitivityLabelsOperations operations - :vartype recommended_sensitivity_labels: azure.mgmt.sql.operations.RecommendedSensitivityLabelsOperations + :vartype recommended_sensitivity_labels: + azure.mgmt.sql.operations.RecommendedSensitivityLabelsOperations :ivar server_advisors: ServerAdvisorsOperations operations :vartype server_advisors: azure.mgmt.sql.operations.ServerAdvisorsOperations :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations :vartype server_automatic_tuning: azure.mgmt.sql.operations.ServerAutomaticTuningOperations :ivar server_azure_ad_administrators: ServerAzureADAdministratorsOperations operations - :vartype server_azure_ad_administrators: azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations - :ivar server_azure_ad_only_authentications: ServerAzureADOnlyAuthenticationsOperations operations - :vartype server_azure_ad_only_authentications: azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations + :vartype server_azure_ad_administrators: + azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations + :ivar server_azure_ad_only_authentications: ServerAzureADOnlyAuthenticationsOperations + operations + :vartype server_azure_ad_only_authentications: + azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations :ivar server_dev_ops_audit_settings: ServerDevOpsAuditSettingsOperations operations - :vartype server_dev_ops_audit_settings: azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations + :vartype server_dev_ops_audit_settings: + azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations :ivar server_dns_aliases: ServerDnsAliasesOperations operations :vartype server_dns_aliases: azure.mgmt.sql.operations.ServerDnsAliasesOperations :ivar server_keys: ServerKeysOperations operations @@ -325,11 +265,13 @@ class SqlManagementClient(object): :ivar server_operations: ServerOperationsOperations operations :vartype server_operations: azure.mgmt.sql.operations.ServerOperationsOperations :ivar server_security_alert_policies: ServerSecurityAlertPoliciesOperations operations - :vartype server_security_alert_policies: azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations + :vartype server_security_alert_policies: + azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations :ivar server_trust_groups: ServerTrustGroupsOperations operations :vartype server_trust_groups: azure.mgmt.sql.operations.ServerTrustGroupsOperations :ivar server_vulnerability_assessments: ServerVulnerabilityAssessmentsOperations operations - :vartype server_vulnerability_assessments: azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations + :vartype server_vulnerability_assessments: + azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations :ivar sql_agent: SqlAgentOperations operations :vartype sql_agent: azure.mgmt.sql.operations.SqlAgentOperations :ivar subscription_usages: SubscriptionUsagesOperations operations @@ -353,9 +295,12 @@ class SqlManagementClient(object): :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.operations.WorkloadGroupsOperations :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations - :vartype transparent_data_encryptions: azure.mgmt.sql.operations.TransparentDataEncryptionsOperations - :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations operations - :vartype backup_short_term_retention_policies: azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations + :vartype transparent_data_encryptions: + azure.mgmt.sql.operations.TransparentDataEncryptionsOperations + :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + operations + :vartype backup_short_term_retention_policies: + azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations :ivar database_extensions: DatabaseExtensionsOperations operations :vartype database_extensions: azure.mgmt.sql.operations.DatabaseExtensionsOperations :ivar database_operations: DatabaseOperationsOperations operations @@ -371,299 +316,196 @@ class SqlManagementClient(object): :ivar usages: UsagesOperations operations :vartype usages: azure.mgmt.sql.operations.UsagesOperations :ivar long_term_retention_backups: LongTermRetentionBackupsOperations operations - :vartype long_term_retention_backups: azure.mgmt.sql.operations.LongTermRetentionBackupsOperations - :ivar long_term_retention_managed_instance_backups: LongTermRetentionManagedInstanceBackupsOperations operations - :vartype long_term_retention_managed_instance_backups: azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations + :vartype long_term_retention_backups: + azure.mgmt.sql.operations.LongTermRetentionBackupsOperations + :ivar long_term_retention_managed_instance_backups: + LongTermRetentionManagedInstanceBackupsOperations operations + :vartype long_term_retention_managed_instance_backups: + azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations :ivar managed_instances: ManagedInstancesOperations operations :vartype managed_instances: azure.mgmt.sql.operations.ManagedInstancesOperations :ivar restorable_dropped_databases: RestorableDroppedDatabasesOperations operations - :vartype restorable_dropped_databases: azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations - :ivar restorable_dropped_managed_databases: RestorableDroppedManagedDatabasesOperations operations - :vartype restorable_dropped_managed_databases: azure.mgmt.sql.operations.RestorableDroppedManagedDatabasesOperations + :vartype restorable_dropped_databases: + azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations + :ivar restorable_dropped_managed_databases: RestorableDroppedManagedDatabasesOperations + operations + :vartype restorable_dropped_managed_databases: + azure.mgmt.sql.operations.RestorableDroppedManagedDatabasesOperations :ivar server_connection_policies: ServerConnectionPoliciesOperations operations - :vartype server_connection_policies: azure.mgmt.sql.operations.ServerConnectionPoliciesOperations + :vartype server_connection_policies: + azure.mgmt.sql.operations.ServerConnectionPoliciesOperations + :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations + :vartype ipv6_firewall_rules: azure.mgmt.sql.operations.IPv6FirewallRulesOperations :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. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SqlManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SqlManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.recoverable_databases = RecoverableDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_masking_policies = DataMaskingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_masking_rules = DataMaskingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.geo_backup_policies = GeoBackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pools = ElasticPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.replication_links = ReplicationLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_communication_links = ServerCommunicationLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_objectives = ServiceObjectivesOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pool_activities = ElasticPoolActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_advisors = DatabaseAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_automatic_tuning = DatabaseAutomaticTuningOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_columns = DatabaseColumnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_recommended_actions = DatabaseRecommendedActionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_schemas = DatabaseSchemasOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pool_operations = ElasticPoolOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_protectors = EncryptionProtectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.instance_failover_groups = InstanceFailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.instance_pools = InstancePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_agents = JobAgentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_credentials = JobCredentialsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_executions = JobExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_step_executions = JobStepExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_steps = JobStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_target_executions = JobTargetExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_target_groups = JobTargetGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_policies = LongTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_window_options = MaintenanceWindowOptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_windows = MaintenanceWindowsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_columns = ManagedDatabaseColumnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_queries = ManagedDatabaseQueriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_databases = ManagedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_schemas = ManagedDatabaseSchemasOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_tables = ManagedDatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_vulnerability_assessment_rule_baselines = ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_administrators = ManagedInstanceAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_keys = ManagedInstanceKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_operations = ManagedInstanceOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_restorable_dropped_database_backup_short_term_retention_policies = ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.recoverable_managed_databases = RecoverableManagedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sensitivity_labels = SensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_automatic_tuning = ServerAutomaticTuningOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_dns_aliases = ServerDnsAliasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_operations = ServerOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_trust_groups = ServerTrustGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_usages = SubscriptionUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_agents = SyncAgentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_groups = SyncGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_members = SyncMembersOperations(self._client, self._config, self._serialize, self._deserialize) + self.tde_certificates = TdeCertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_clusters = VirtualClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_network_rules = VirtualNetworkRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.workload_classifiers = WorkloadClassifiersOperations(self._client, self._config, self._serialize, self._deserialize) + self.workload_groups = WorkloadGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_extensions = DatabaseExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_operations = DatabaseOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_usages = DatabaseUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ledger_digest_uploads = LedgerDigestUploadsOperations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_firewall_rules = OutboundFirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_backups = LongTermRetentionBackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instances = ManagedInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_connection_policies = ServerConnectionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ipv6_firewall_rules = IPv6FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.recoverable_databases = RecoverableDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_masking_policies = DataMaskingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_masking_rules = DataMaskingRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.geo_backup_policies = GeoBackupPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pools = ElasticPoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.replication_links = ReplicationLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_communication_links = ServerCommunicationLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_objectives = ServiceObjectivesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_activities = ElasticPoolActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_usages = ServerUsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_advisors = DatabaseAdvisorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_automatic_tuning = DatabaseAutomaticTuningOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_columns = DatabaseColumnsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_recommended_actions = DatabaseRecommendedActionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_schemas = DatabaseSchemasOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_tables = DatabaseTablesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deleted_servers = DeletedServersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_operations = ElasticPoolOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.encryption_protectors = EncryptionProtectorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.failover_groups = FailoverGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.instance_failover_groups = InstanceFailoverGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.instance_pools = InstancePoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_agents = JobAgentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_credentials = JobCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_executions = JobExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_step_executions = JobStepExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_steps = JobStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_target_executions = JobTargetExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_target_groups = JobTargetGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_versions = JobVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.capabilities = CapabilitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_policies = LongTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_window_options = MaintenanceWindowOptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_windows = MaintenanceWindowsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_columns = ManagedDatabaseColumnsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_queries = ManagedDatabaseQueriesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_databases = ManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_schemas = ManagedDatabaseSchemasOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_tables = ManagedDatabaseTablesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_vulnerability_assessment_rule_baselines = ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_keys = ManagedInstanceKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_operations = ManagedInstanceOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_restorable_dropped_database_backup_short_term_retention_policies = ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.operations_health = OperationsHealthOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sensitivity_labels = SensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_advisors = ServerAdvisorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_automatic_tuning = ServerAutomaticTuningOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_dns_aliases = ServerDnsAliasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_keys = ServerKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_operations = ServerOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_trust_groups = ServerTrustGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sql_agent = SqlAgentOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_usages = SubscriptionUsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_agents = SyncAgentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_groups = SyncGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_members = SyncMembersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tde_certificates = TdeCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.time_zones = TimeZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_clusters = VirtualClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_rules = VirtualNetworkRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workload_classifiers = WorkloadClassifiersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workload_groups = WorkloadGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_extensions = DatabaseExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_operations = DatabaseOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_usages = DatabaseUsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.ledger_digest_uploads = LedgerDigestUploadsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.outbound_firewall_rules = OutboundFirewallRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.servers = ServersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_backups = LongTermRetentionBackupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instances = ManagedInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_connection_policies = ServerConnectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_vendor.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) 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 3073d7c910a0b..c78e629b6f086 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.0b1" +VERSION = "0.9.0" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py index 92b4087c323eb..610e1a2780ac8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py @@ -8,3 +8,8 @@ from ._sql_management_client import SqlManagementClient __all__ = ['SqlManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_configuration.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_configuration.py index ae2d37d3a0657..087ec14fcc375 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_configuration.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(SqlManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(SqlManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_patch.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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 d7ce36546c20a..fae0d0597036b 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 @@ -6,140 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SqlManagementClientConfiguration +from .operations import BackupShortTermRetentionPoliciesOperations, CapabilitiesOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, DataWarehouseUserActivitiesOperations, DatabaseAdvisorsOperations, DatabaseAutomaticTuningOperations, DatabaseBlobAuditingPoliciesOperations, DatabaseColumnsOperations, DatabaseExtensionsOperations, DatabaseOperationsOperations, DatabaseRecommendedActionsOperations, DatabaseSchemasOperations, DatabaseSecurityAlertPoliciesOperations, DatabaseTablesOperations, DatabaseUsagesOperations, DatabaseVulnerabilityAssessmentRuleBaselinesOperations, DatabaseVulnerabilityAssessmentScansOperations, DatabaseVulnerabilityAssessmentsOperations, DatabasesOperations, DeletedServersOperations, ElasticPoolActivitiesOperations, ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, 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, ManagedServerSecurityAlertPoliciesOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RecommendedSensitivityLabelsOperations, RecoverableDatabasesOperations, RecoverableManagedDatabasesOperations, ReplicationLinksOperations, RestorableDroppedDatabasesOperations, RestorableDroppedManagedDatabasesOperations, RestorePointsOperations, SensitivityLabelsOperations, ServerAdvisorsOperations, ServerAutomaticTuningOperations, ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, ServerCommunicationLinksOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, ServerDnsAliasesOperations, ServerKeysOperations, ServerOperationsOperations, ServerSecurityAlertPoliciesOperations, 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 from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SqlManagementClientConfiguration -from .operations import RecoverableDatabasesOperations -from .operations import DataMaskingPoliciesOperations -from .operations import DataMaskingRulesOperations -from .operations import GeoBackupPoliciesOperations -from .operations import DatabasesOperations -from .operations import ElasticPoolsOperations -from .operations import ReplicationLinksOperations -from .operations import ServerCommunicationLinksOperations -from .operations import ServiceObjectivesOperations -from .operations import ElasticPoolActivitiesOperations -from .operations import ElasticPoolDatabaseActivitiesOperations -from .operations import ServerUsagesOperations -from .operations import ExtendedDatabaseBlobAuditingPoliciesOperations -from .operations import ExtendedServerBlobAuditingPoliciesOperations -from .operations import ServerBlobAuditingPoliciesOperations -from .operations import DatabaseBlobAuditingPoliciesOperations -from .operations import DatabaseAdvisorsOperations -from .operations import DatabaseAutomaticTuningOperations -from .operations import DatabaseColumnsOperations -from .operations import DatabaseRecommendedActionsOperations -from .operations import DatabaseSchemasOperations -from .operations import DatabaseSecurityAlertPoliciesOperations -from .operations import DatabaseTablesOperations -from .operations import DatabaseVulnerabilityAssessmentRuleBaselinesOperations -from .operations import DatabaseVulnerabilityAssessmentsOperations -from .operations import DatabaseVulnerabilityAssessmentScansOperations -from .operations import DataWarehouseUserActivitiesOperations -from .operations import DeletedServersOperations -from .operations import ElasticPoolOperationsOperations -from .operations import EncryptionProtectorsOperations -from .operations import FailoverGroupsOperations -from .operations import FirewallRulesOperations -from .operations import InstanceFailoverGroupsOperations -from .operations import InstancePoolsOperations -from .operations import JobAgentsOperations -from .operations import JobCredentialsOperations -from .operations import JobExecutionsOperations -from .operations import JobsOperations -from .operations import JobStepExecutionsOperations -from .operations import JobStepsOperations -from .operations import JobTargetExecutionsOperations -from .operations import JobTargetGroupsOperations -from .operations import JobVersionsOperations -from .operations import CapabilitiesOperations -from .operations import LongTermRetentionPoliciesOperations -from .operations import MaintenanceWindowOptionsOperations -from .operations import MaintenanceWindowsOperations -from .operations import ManagedBackupShortTermRetentionPoliciesOperations -from .operations import ManagedDatabaseColumnsOperations -from .operations import ManagedDatabaseQueriesOperations -from .operations import ManagedDatabaseRestoreDetailsOperations -from .operations import ManagedDatabasesOperations -from .operations import ManagedDatabaseSchemasOperations -from .operations import ManagedDatabaseSecurityAlertPoliciesOperations -from .operations import ManagedDatabaseSecurityEventsOperations -from .operations import ManagedDatabaseSensitivityLabelsOperations -from .operations import ManagedDatabaseRecommendedSensitivityLabelsOperations -from .operations import ManagedDatabaseTablesOperations -from .operations import ManagedDatabaseTransparentDataEncryptionOperations -from .operations import ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations -from .operations import ManagedDatabaseVulnerabilityAssessmentsOperations -from .operations import ManagedDatabaseVulnerabilityAssessmentScansOperations -from .operations import ManagedInstanceAdministratorsOperations -from .operations import ManagedInstanceAzureADOnlyAuthenticationsOperations -from .operations import ManagedInstanceEncryptionProtectorsOperations -from .operations import ManagedInstanceKeysOperations -from .operations import ManagedInstanceLongTermRetentionPoliciesOperations -from .operations import ManagedInstanceOperationsOperations -from .operations import ManagedInstancePrivateEndpointConnectionsOperations -from .operations import ManagedInstancePrivateLinkResourcesOperations -from .operations import ManagedInstanceTdeCertificatesOperations -from .operations import ManagedInstanceVulnerabilityAssessmentsOperations -from .operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations -from .operations import ManagedServerSecurityAlertPoliciesOperations -from .operations import Operations -from .operations import OperationsHealthOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import RecoverableManagedDatabasesOperations -from .operations import RestorePointsOperations -from .operations import SensitivityLabelsOperations -from .operations import RecommendedSensitivityLabelsOperations -from .operations import ServerAdvisorsOperations -from .operations import ServerAutomaticTuningOperations -from .operations import ServerAzureADAdministratorsOperations -from .operations import ServerAzureADOnlyAuthenticationsOperations -from .operations import ServerDevOpsAuditSettingsOperations -from .operations import ServerDnsAliasesOperations -from .operations import ServerKeysOperations -from .operations import ServerOperationsOperations -from .operations import ServerSecurityAlertPoliciesOperations -from .operations import ServerTrustGroupsOperations -from .operations import ServerVulnerabilityAssessmentsOperations -from .operations import SqlAgentOperations -from .operations import SubscriptionUsagesOperations -from .operations import SyncAgentsOperations -from .operations import SyncGroupsOperations -from .operations import SyncMembersOperations -from .operations import TdeCertificatesOperations -from .operations import TimeZonesOperations -from .operations import VirtualClustersOperations -from .operations import VirtualNetworkRulesOperations -from .operations import WorkloadClassifiersOperations -from .operations import WorkloadGroupsOperations -from .operations import TransparentDataEncryptionsOperations -from .operations import BackupShortTermRetentionPoliciesOperations -from .operations import DatabaseExtensionsOperations -from .operations import DatabaseOperationsOperations -from .operations import DatabaseUsagesOperations -from .operations import LedgerDigestUploadsOperations -from .operations import OutboundFirewallRulesOperations -from .operations import ServersOperations -from .operations import UsagesOperations -from .operations import LongTermRetentionBackupsOperations -from .operations import LongTermRetentionManagedInstanceBackupsOperations -from .operations import ManagedInstancesOperations -from .operations import RestorableDroppedDatabasesOperations -from .operations import RestorableDroppedManagedDatabasesOperations -from .operations import ServerConnectionPoliciesOperations -from .. import models - - -class SqlManagementClient(object): +class SqlManagementClient: """The Azure SQL Database management API provides a RESTful set of web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete databases. :ivar recoverable_databases: RecoverableDatabasesOperations operations @@ -157,45 +39,62 @@ class SqlManagementClient(object): :ivar replication_links: ReplicationLinksOperations operations :vartype replication_links: azure.mgmt.sql.aio.operations.ReplicationLinksOperations :ivar server_communication_links: ServerCommunicationLinksOperations operations - :vartype server_communication_links: azure.mgmt.sql.aio.operations.ServerCommunicationLinksOperations + :vartype server_communication_links: + azure.mgmt.sql.aio.operations.ServerCommunicationLinksOperations :ivar service_objectives: ServiceObjectivesOperations operations :vartype service_objectives: azure.mgmt.sql.aio.operations.ServiceObjectivesOperations :ivar elastic_pool_activities: ElasticPoolActivitiesOperations operations :vartype elastic_pool_activities: azure.mgmt.sql.aio.operations.ElasticPoolActivitiesOperations :ivar elastic_pool_database_activities: ElasticPoolDatabaseActivitiesOperations operations - :vartype elastic_pool_database_activities: azure.mgmt.sql.aio.operations.ElasticPoolDatabaseActivitiesOperations + :vartype elastic_pool_database_activities: + azure.mgmt.sql.aio.operations.ElasticPoolDatabaseActivitiesOperations :ivar server_usages: ServerUsagesOperations operations :vartype server_usages: azure.mgmt.sql.aio.operations.ServerUsagesOperations - :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations operations - :vartype extended_database_blob_auditing_policies: azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations - :ivar extended_server_blob_auditing_policies: ExtendedServerBlobAuditingPoliciesOperations operations - :vartype extended_server_blob_auditing_policies: azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations + :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations + operations + :vartype extended_database_blob_auditing_policies: + azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations + :ivar extended_server_blob_auditing_policies: ExtendedServerBlobAuditingPoliciesOperations + operations + :vartype extended_server_blob_auditing_policies: + azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations - :vartype server_blob_auditing_policies: azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations + :vartype server_blob_auditing_policies: + azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations :ivar database_blob_auditing_policies: DatabaseBlobAuditingPoliciesOperations operations - :vartype database_blob_auditing_policies: azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations + :vartype database_blob_auditing_policies: + azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations :ivar database_advisors: DatabaseAdvisorsOperations operations :vartype database_advisors: azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations :ivar database_automatic_tuning: DatabaseAutomaticTuningOperations operations - :vartype database_automatic_tuning: azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations + :vartype database_automatic_tuning: + azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations :ivar database_columns: DatabaseColumnsOperations operations :vartype database_columns: azure.mgmt.sql.aio.operations.DatabaseColumnsOperations :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations - :vartype database_recommended_actions: azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations + :vartype database_recommended_actions: + azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations :ivar database_schemas: DatabaseSchemasOperations operations :vartype database_schemas: azure.mgmt.sql.aio.operations.DatabaseSchemasOperations :ivar database_security_alert_policies: DatabaseSecurityAlertPoliciesOperations operations - :vartype database_security_alert_policies: azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations + :vartype database_security_alert_policies: + azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations :ivar database_tables: DatabaseTablesOperations operations :vartype database_tables: azure.mgmt.sql.aio.operations.DatabaseTablesOperations - :ivar database_vulnerability_assessment_rule_baselines: DatabaseVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype database_vulnerability_assessment_rule_baselines: azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations + :ivar database_vulnerability_assessment_rule_baselines: + DatabaseVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype database_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations :ivar database_vulnerability_assessments: DatabaseVulnerabilityAssessmentsOperations operations - :vartype database_vulnerability_assessments: azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations - :ivar database_vulnerability_assessment_scans: DatabaseVulnerabilityAssessmentScansOperations operations - :vartype database_vulnerability_assessment_scans: azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations + :vartype database_vulnerability_assessments: + azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations + :ivar database_vulnerability_assessment_scans: DatabaseVulnerabilityAssessmentScansOperations + operations + :vartype database_vulnerability_assessment_scans: + azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations - :vartype data_warehouse_user_activities: azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations + :vartype data_warehouse_user_activities: + azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations :ivar deleted_servers: DeletedServersOperations operations :vartype deleted_servers: azure.mgmt.sql.aio.operations.DeletedServersOperations :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations @@ -207,7 +106,8 @@ class SqlManagementClient(object): :ivar firewall_rules: FirewallRulesOperations operations :vartype firewall_rules: azure.mgmt.sql.aio.operations.FirewallRulesOperations :ivar instance_failover_groups: InstanceFailoverGroupsOperations operations - :vartype instance_failover_groups: azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations + :vartype instance_failover_groups: + azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations :ivar instance_pools: InstancePoolsOperations operations :vartype instance_pools: azure.mgmt.sql.aio.operations.InstancePoolsOperations :ivar job_agents: JobAgentsOperations operations @@ -231,91 +131,138 @@ class SqlManagementClient(object): :ivar capabilities: CapabilitiesOperations operations :vartype capabilities: azure.mgmt.sql.aio.operations.CapabilitiesOperations :ivar long_term_retention_policies: LongTermRetentionPoliciesOperations operations - :vartype long_term_retention_policies: azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations + :vartype long_term_retention_policies: + azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations :ivar maintenance_window_options: MaintenanceWindowOptionsOperations operations - :vartype maintenance_window_options: azure.mgmt.sql.aio.operations.MaintenanceWindowOptionsOperations + :vartype maintenance_window_options: + azure.mgmt.sql.aio.operations.MaintenanceWindowOptionsOperations :ivar maintenance_windows: MaintenanceWindowsOperations operations :vartype maintenance_windows: azure.mgmt.sql.aio.operations.MaintenanceWindowsOperations - :ivar managed_backup_short_term_retention_policies: ManagedBackupShortTermRetentionPoliciesOperations operations - :vartype managed_backup_short_term_retention_policies: azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations + :ivar managed_backup_short_term_retention_policies: + ManagedBackupShortTermRetentionPoliciesOperations operations + :vartype managed_backup_short_term_retention_policies: + azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations - :vartype managed_database_columns: azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations + :vartype managed_database_columns: + azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations :ivar managed_database_queries: ManagedDatabaseQueriesOperations operations - :vartype managed_database_queries: azure.mgmt.sql.aio.operations.ManagedDatabaseQueriesOperations + :vartype managed_database_queries: + azure.mgmt.sql.aio.operations.ManagedDatabaseQueriesOperations :ivar managed_database_restore_details: ManagedDatabaseRestoreDetailsOperations operations - :vartype managed_database_restore_details: azure.mgmt.sql.aio.operations.ManagedDatabaseRestoreDetailsOperations + :vartype managed_database_restore_details: + azure.mgmt.sql.aio.operations.ManagedDatabaseRestoreDetailsOperations :ivar managed_databases: ManagedDatabasesOperations operations :vartype managed_databases: azure.mgmt.sql.aio.operations.ManagedDatabasesOperations :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations - :vartype managed_database_schemas: azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations - :ivar managed_database_security_alert_policies: ManagedDatabaseSecurityAlertPoliciesOperations operations - :vartype managed_database_security_alert_policies: azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations + :vartype managed_database_schemas: + azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations + :ivar managed_database_security_alert_policies: ManagedDatabaseSecurityAlertPoliciesOperations + operations + :vartype managed_database_security_alert_policies: + azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations :ivar managed_database_security_events: ManagedDatabaseSecurityEventsOperations operations - :vartype managed_database_security_events: azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityEventsOperations - :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations operations - :vartype managed_database_sensitivity_labels: azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations - :ivar managed_database_recommended_sensitivity_labels: ManagedDatabaseRecommendedSensitivityLabelsOperations operations - :vartype managed_database_recommended_sensitivity_labels: azure.mgmt.sql.aio.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations + :vartype managed_database_security_events: + azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityEventsOperations + :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations + operations + :vartype managed_database_sensitivity_labels: + azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations + :ivar managed_database_recommended_sensitivity_labels: + ManagedDatabaseRecommendedSensitivityLabelsOperations operations + :vartype managed_database_recommended_sensitivity_labels: + azure.mgmt.sql.aio.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations :ivar managed_database_tables: ManagedDatabaseTablesOperations operations :vartype managed_database_tables: azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations - :ivar managed_database_transparent_data_encryption: ManagedDatabaseTransparentDataEncryptionOperations operations - :vartype managed_database_transparent_data_encryption: azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations - :ivar managed_database_vulnerability_assessment_rule_baselines: ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype managed_database_vulnerability_assessment_rule_baselines: azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations - :ivar managed_database_vulnerability_assessments: ManagedDatabaseVulnerabilityAssessmentsOperations operations - :vartype managed_database_vulnerability_assessments: azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations - :ivar managed_database_vulnerability_assessment_scans: ManagedDatabaseVulnerabilityAssessmentScansOperations operations - :vartype managed_database_vulnerability_assessment_scans: azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations + :ivar managed_database_transparent_data_encryption: + ManagedDatabaseTransparentDataEncryptionOperations operations + :vartype managed_database_transparent_data_encryption: + azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations + :ivar managed_database_vulnerability_assessment_rule_baselines: + ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype managed_database_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations + :ivar managed_database_vulnerability_assessments: + ManagedDatabaseVulnerabilityAssessmentsOperations operations + :vartype managed_database_vulnerability_assessments: + azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations + :ivar managed_database_vulnerability_assessment_scans: + ManagedDatabaseVulnerabilityAssessmentScansOperations operations + :vartype managed_database_vulnerability_assessment_scans: + azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations :ivar managed_instance_administrators: ManagedInstanceAdministratorsOperations operations - :vartype managed_instance_administrators: azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations - :ivar managed_instance_azure_ad_only_authentications: ManagedInstanceAzureADOnlyAuthenticationsOperations operations - :vartype managed_instance_azure_ad_only_authentications: azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations - :ivar managed_instance_encryption_protectors: ManagedInstanceEncryptionProtectorsOperations operations - :vartype managed_instance_encryption_protectors: azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations + :vartype managed_instance_administrators: + azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations + :ivar managed_instance_azure_ad_only_authentications: + ManagedInstanceAzureADOnlyAuthenticationsOperations operations + :vartype managed_instance_azure_ad_only_authentications: + azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations + :ivar managed_instance_encryption_protectors: ManagedInstanceEncryptionProtectorsOperations + operations + :vartype managed_instance_encryption_protectors: + azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations :ivar managed_instance_keys: ManagedInstanceKeysOperations operations :vartype managed_instance_keys: azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations - :ivar managed_instance_long_term_retention_policies: ManagedInstanceLongTermRetentionPoliciesOperations operations - :vartype managed_instance_long_term_retention_policies: azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations + :ivar managed_instance_long_term_retention_policies: + ManagedInstanceLongTermRetentionPoliciesOperations operations + :vartype managed_instance_long_term_retention_policies: + azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations :ivar managed_instance_operations: ManagedInstanceOperationsOperations operations - :vartype managed_instance_operations: azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations - :ivar managed_instance_private_endpoint_connections: ManagedInstancePrivateEndpointConnectionsOperations operations - :vartype managed_instance_private_endpoint_connections: azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations - :ivar managed_instance_private_link_resources: ManagedInstancePrivateLinkResourcesOperations operations - :vartype managed_instance_private_link_resources: azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations + :vartype managed_instance_operations: + azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations + :ivar managed_instance_private_endpoint_connections: + ManagedInstancePrivateEndpointConnectionsOperations operations + :vartype managed_instance_private_endpoint_connections: + azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations + :ivar managed_instance_private_link_resources: ManagedInstancePrivateLinkResourcesOperations + operations + :vartype managed_instance_private_link_resources: + azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations :ivar managed_instance_tde_certificates: ManagedInstanceTdeCertificatesOperations operations - :vartype managed_instance_tde_certificates: azure.mgmt.sql.aio.operations.ManagedInstanceTdeCertificatesOperations - :ivar managed_instance_vulnerability_assessments: ManagedInstanceVulnerabilityAssessmentsOperations operations - :vartype managed_instance_vulnerability_assessments: azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations - :ivar managed_restorable_dropped_database_backup_short_term_retention_policies: ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations operations - :vartype managed_restorable_dropped_database_backup_short_term_retention_policies: azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations - :ivar managed_server_security_alert_policies: ManagedServerSecurityAlertPoliciesOperations operations - :vartype managed_server_security_alert_policies: azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations + :vartype managed_instance_tde_certificates: + azure.mgmt.sql.aio.operations.ManagedInstanceTdeCertificatesOperations + :ivar managed_instance_vulnerability_assessments: + ManagedInstanceVulnerabilityAssessmentsOperations operations + :vartype managed_instance_vulnerability_assessments: + azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations + :ivar managed_restorable_dropped_database_backup_short_term_retention_policies: + ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations operations + :vartype managed_restorable_dropped_database_backup_short_term_retention_policies: + azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations + :ivar managed_server_security_alert_policies: ManagedServerSecurityAlertPoliciesOperations + operations + :vartype managed_server_security_alert_policies: + azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.sql.aio.operations.Operations - :ivar operations_health: OperationsHealthOperations operations - :vartype operations_health: azure.mgmt.sql.aio.operations.OperationsHealthOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.sql.aio.operations.PrivateLinkResourcesOperations :ivar recoverable_managed_databases: RecoverableManagedDatabasesOperations operations - :vartype recoverable_managed_databases: azure.mgmt.sql.aio.operations.RecoverableManagedDatabasesOperations + :vartype recoverable_managed_databases: + azure.mgmt.sql.aio.operations.RecoverableManagedDatabasesOperations :ivar restore_points: RestorePointsOperations operations :vartype restore_points: azure.mgmt.sql.aio.operations.RestorePointsOperations :ivar sensitivity_labels: SensitivityLabelsOperations operations :vartype sensitivity_labels: azure.mgmt.sql.aio.operations.SensitivityLabelsOperations :ivar recommended_sensitivity_labels: RecommendedSensitivityLabelsOperations operations - :vartype recommended_sensitivity_labels: azure.mgmt.sql.aio.operations.RecommendedSensitivityLabelsOperations + :vartype recommended_sensitivity_labels: + azure.mgmt.sql.aio.operations.RecommendedSensitivityLabelsOperations :ivar server_advisors: ServerAdvisorsOperations operations :vartype server_advisors: azure.mgmt.sql.aio.operations.ServerAdvisorsOperations :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations :vartype server_automatic_tuning: azure.mgmt.sql.aio.operations.ServerAutomaticTuningOperations :ivar server_azure_ad_administrators: ServerAzureADAdministratorsOperations operations - :vartype server_azure_ad_administrators: azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations - :ivar server_azure_ad_only_authentications: ServerAzureADOnlyAuthenticationsOperations operations - :vartype server_azure_ad_only_authentications: azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations + :vartype server_azure_ad_administrators: + azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations + :ivar server_azure_ad_only_authentications: ServerAzureADOnlyAuthenticationsOperations + operations + :vartype server_azure_ad_only_authentications: + azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations :ivar server_dev_ops_audit_settings: ServerDevOpsAuditSettingsOperations operations - :vartype server_dev_ops_audit_settings: azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations + :vartype server_dev_ops_audit_settings: + azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations :ivar server_dns_aliases: ServerDnsAliasesOperations operations :vartype server_dns_aliases: azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations :ivar server_keys: ServerKeysOperations operations @@ -323,11 +270,13 @@ class SqlManagementClient(object): :ivar server_operations: ServerOperationsOperations operations :vartype server_operations: azure.mgmt.sql.aio.operations.ServerOperationsOperations :ivar server_security_alert_policies: ServerSecurityAlertPoliciesOperations operations - :vartype server_security_alert_policies: azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations + :vartype server_security_alert_policies: + azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations :ivar server_trust_groups: ServerTrustGroupsOperations operations :vartype server_trust_groups: azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations :ivar server_vulnerability_assessments: ServerVulnerabilityAssessmentsOperations operations - :vartype server_vulnerability_assessments: azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations + :vartype server_vulnerability_assessments: + azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations :ivar sql_agent: SqlAgentOperations operations :vartype sql_agent: azure.mgmt.sql.aio.operations.SqlAgentOperations :ivar subscription_usages: SubscriptionUsagesOperations operations @@ -351,9 +300,12 @@ class SqlManagementClient(object): :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.aio.operations.WorkloadGroupsOperations :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations - :vartype transparent_data_encryptions: azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations - :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations operations - :vartype backup_short_term_retention_policies: azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations + :vartype transparent_data_encryptions: + azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations + :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + operations + :vartype backup_short_term_retention_policies: + azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations :ivar database_extensions: DatabaseExtensionsOperations operations :vartype database_extensions: azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations :ivar database_operations: DatabaseOperationsOperations operations @@ -369,297 +321,196 @@ class SqlManagementClient(object): :ivar usages: UsagesOperations operations :vartype usages: azure.mgmt.sql.aio.operations.UsagesOperations :ivar long_term_retention_backups: LongTermRetentionBackupsOperations operations - :vartype long_term_retention_backups: azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations - :ivar long_term_retention_managed_instance_backups: LongTermRetentionManagedInstanceBackupsOperations operations - :vartype long_term_retention_managed_instance_backups: azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations + :vartype long_term_retention_backups: + azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations + :ivar long_term_retention_managed_instance_backups: + LongTermRetentionManagedInstanceBackupsOperations operations + :vartype long_term_retention_managed_instance_backups: + azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations :ivar managed_instances: ManagedInstancesOperations operations :vartype managed_instances: azure.mgmt.sql.aio.operations.ManagedInstancesOperations :ivar restorable_dropped_databases: RestorableDroppedDatabasesOperations operations - :vartype restorable_dropped_databases: azure.mgmt.sql.aio.operations.RestorableDroppedDatabasesOperations - :ivar restorable_dropped_managed_databases: RestorableDroppedManagedDatabasesOperations operations - :vartype restorable_dropped_managed_databases: azure.mgmt.sql.aio.operations.RestorableDroppedManagedDatabasesOperations + :vartype restorable_dropped_databases: + azure.mgmt.sql.aio.operations.RestorableDroppedDatabasesOperations + :ivar restorable_dropped_managed_databases: RestorableDroppedManagedDatabasesOperations + operations + :vartype restorable_dropped_managed_databases: + azure.mgmt.sql.aio.operations.RestorableDroppedManagedDatabasesOperations :ivar server_connection_policies: ServerConnectionPoliciesOperations operations - :vartype server_connection_policies: azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations + :vartype server_connection_policies: + azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations + :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations + :vartype ipv6_firewall_rules: azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations :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. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = SqlManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = SqlManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.recoverable_databases = RecoverableDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_masking_policies = DataMaskingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_masking_rules = DataMaskingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.geo_backup_policies = GeoBackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pools = ElasticPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.replication_links = ReplicationLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_communication_links = ServerCommunicationLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_objectives = ServiceObjectivesOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pool_activities = ElasticPoolActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_advisors = DatabaseAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_automatic_tuning = DatabaseAutomaticTuningOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_columns = DatabaseColumnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_recommended_actions = DatabaseRecommendedActionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_schemas = DatabaseSchemasOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.elastic_pool_operations = ElasticPoolOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_protectors = EncryptionProtectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.instance_failover_groups = InstanceFailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.instance_pools = InstancePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_agents = JobAgentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_credentials = JobCredentialsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_executions = JobExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_step_executions = JobStepExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_steps = JobStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_target_executions = JobTargetExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_target_groups = JobTargetGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_policies = LongTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_window_options = MaintenanceWindowOptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_windows = MaintenanceWindowsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_columns = ManagedDatabaseColumnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_queries = ManagedDatabaseQueriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_databases = ManagedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_schemas = ManagedDatabaseSchemasOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_tables = ManagedDatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_vulnerability_assessment_rule_baselines = ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_administrators = ManagedInstanceAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_keys = ManagedInstanceKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_operations = ManagedInstanceOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_restorable_dropped_database_backup_short_term_retention_policies = ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.recoverable_managed_databases = RecoverableManagedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sensitivity_labels = SensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_automatic_tuning = ServerAutomaticTuningOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_dns_aliases = ServerDnsAliasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_operations = ServerOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_trust_groups = ServerTrustGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_usages = SubscriptionUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_agents = SyncAgentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_groups = SyncGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_members = SyncMembersOperations(self._client, self._config, self._serialize, self._deserialize) + self.tde_certificates = TdeCertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_clusters = VirtualClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_network_rules = VirtualNetworkRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.workload_classifiers = WorkloadClassifiersOperations(self._client, self._config, self._serialize, self._deserialize) + self.workload_groups = WorkloadGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_extensions = DatabaseExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_operations = DatabaseOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_usages = DatabaseUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ledger_digest_uploads = LedgerDigestUploadsOperations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_firewall_rules = OutboundFirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_backups = LongTermRetentionBackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_instances = ManagedInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_connection_policies = ServerConnectionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ipv6_firewall_rules = IPv6FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.recoverable_databases = RecoverableDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_masking_policies = DataMaskingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_masking_rules = DataMaskingRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.geo_backup_policies = GeoBackupPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pools = ElasticPoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.replication_links = ReplicationLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_communication_links = ServerCommunicationLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_objectives = ServiceObjectivesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_activities = ElasticPoolActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_usages = ServerUsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_advisors = DatabaseAdvisorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_automatic_tuning = DatabaseAutomaticTuningOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_columns = DatabaseColumnsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_recommended_actions = DatabaseRecommendedActionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_schemas = DatabaseSchemasOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_tables = DatabaseTablesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deleted_servers = DeletedServersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_operations = ElasticPoolOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.encryption_protectors = EncryptionProtectorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.failover_groups = FailoverGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.instance_failover_groups = InstanceFailoverGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.instance_pools = InstancePoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_agents = JobAgentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_credentials = JobCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_executions = JobExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_step_executions = JobStepExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_steps = JobStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_target_executions = JobTargetExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_target_groups = JobTargetGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_versions = JobVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.capabilities = CapabilitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_policies = LongTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_window_options = MaintenanceWindowOptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_windows = MaintenanceWindowsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_columns = ManagedDatabaseColumnsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_queries = ManagedDatabaseQueriesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_databases = ManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_schemas = ManagedDatabaseSchemasOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_tables = ManagedDatabaseTablesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_vulnerability_assessment_rule_baselines = ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_keys = ManagedInstanceKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_operations = ManagedInstanceOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_restorable_dropped_database_backup_short_term_retention_policies = ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.operations_health = OperationsHealthOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sensitivity_labels = SensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_advisors = ServerAdvisorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_automatic_tuning = ServerAutomaticTuningOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_dns_aliases = ServerDnsAliasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_keys = ServerKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_operations = ServerOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_trust_groups = ServerTrustGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sql_agent = SqlAgentOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_usages = SubscriptionUsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_agents = SyncAgentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_groups = SyncGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_members = SyncMembersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tde_certificates = TdeCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.time_zones = TimeZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_clusters = VirtualClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_rules = VirtualNetworkRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workload_classifiers = WorkloadClassifiersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workload_groups = WorkloadGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_extensions = DatabaseExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_operations = DatabaseOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.database_usages = DatabaseUsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.ledger_digest_uploads = LedgerDigestUploadsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.outbound_firewall_rules = OutboundFirewallRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.servers = ServersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_backups = LongTermRetentionBackupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.managed_instances = ManagedInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_connection_policies = ServerConnectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() 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 f990cc3c49eaa..8d0b2ee774068 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 @@ -81,7 +81,6 @@ from ._managed_restorable_dropped_database_backup_short_term_retention_policies_operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations from ._managed_server_security_alert_policies_operations import ManagedServerSecurityAlertPoliciesOperations from ._operations import Operations -from ._operations_health_operations import OperationsHealthOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._recoverable_managed_databases_operations import RecoverableManagedDatabasesOperations @@ -125,6 +124,7 @@ from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations from ._server_connection_policies_operations import ServerConnectionPoliciesOperations +from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations __all__ = [ 'RecoverableDatabasesOperations', @@ -202,7 +202,6 @@ 'ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations', 'ManagedServerSecurityAlertPoliciesOperations', 'Operations', - 'OperationsHealthOperations', 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', 'RecoverableManagedDatabasesOperations', @@ -246,4 +245,5 @@ 'RestorableDroppedDatabasesOperations', 'RestorableDroppedManagedDatabasesOperations', 'ServerConnectionPoliciesOperations', + 'IPv6FirewallRulesOperations', ] diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_backup_short_term_retention_policies_operations.py index a6f3c926790e2..d555131c178c9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_backup_short_term_retention_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._backup_short_term_retention_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_database_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,29 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -124,34 +122,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +155,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -193,15 +184,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy :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. + :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 BackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 BackupShortTermRetentionPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,29 +211,21 @@ async def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,6 +237,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore async def _update_initial( @@ -265,34 +254,24 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,8 +287,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -334,15 +316,20 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy :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. + :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 BackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 BackupShortTermRetentionPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -356,29 +343,21 @@ async def begin_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -390,8 +369,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -409,8 +390,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupShortTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicyListResult] + :return: An iterator like instance of either BackupShortTermRetentionPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupShortTermRetentionPolicyListResult"] @@ -418,37 +401,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BackupShortTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("BackupShortTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -466,6 +447,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_capabilities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_capabilities_operations.py index 5566230860a1f..fda90048da91c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_capabilities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_capabilities_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._capabilities_operations import build_list_by_location_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_location( self, location_name: str, @@ -62,28 +67,17 @@ async def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if include is not None: - query_parameters['include'] = self._serialize.query("include", include, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + include=include, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,4 +91,6 @@ async def list_by_location( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py index 2aec6dca47c39..1040591353ace 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._data_masking_policies_operations import build_create_or_update_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -69,35 +74,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DataMaskingPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataMaskingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,8 +104,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -139,30 +135,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,4 +160,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py index da20d48a80b7c..8b96a3a214106 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._data_masking_rules_operations import build_create_or_update_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -73,36 +79,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - 'dataMaskingRuleName': self._serialize.url("data_masking_rule_name", data_masking_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DataMaskingRule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_masking_rule_name=data_masking_rule_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataMaskingRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -120,8 +114,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -139,8 +136,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataMaskingRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataMaskingRuleListResult] + :return: An iterator like instance of either DataMaskingRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataMaskingRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingRuleListResult"] @@ -148,39 +147,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataMaskingRuleListResult', pipeline_response) + deserialized = self._deserialize("DataMaskingRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,6 +193,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_warehouse_user_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_warehouse_user_activities_operations.py index aa832ed4c5186..ec54e14fc6434 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_warehouse_user_activities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_warehouse_user_activities_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._data_warehouse_user_activities_operations import build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -59,7 +65,8 @@ async def get( :param database_name: The name of the database. :type database_name: str :param data_warehouse_user_activity_name: The activity name of the data warehouse. - :type data_warehouse_user_activity_name: str or ~azure.mgmt.sql.models.DataWarehouseUserActivityName + :type data_warehouse_user_activity_name: str or + ~azure.mgmt.sql.models.DataWarehouseUserActivityName :keyword callable cls: A custom type or function that will be passed the direct response :return: DataWarehouseUserActivities, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataWarehouseUserActivities @@ -70,29 +77,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataWarehouseUserActivityName': self._serialize.url("data_warehouse_user_activity_name", data_warehouse_user_activity_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_warehouse_user_activity_name=data_warehouse_user_activity_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +103,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -125,8 +125,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataWarehouseUserActivitiesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivitiesListResult] + :return: An iterator like instance of either DataWarehouseUserActivitiesListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataWarehouseUserActivitiesListResult"] @@ -134,37 +136,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataWarehouseUserActivitiesListResult', pipeline_response) + deserialized = self._deserialize("DataWarehouseUserActivitiesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -182,6 +182,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advisors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advisors_operations.py index e48698ffc11b3..243a8b5e013cb 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advisors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advisors_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_advisors_operations import build_get_request, build_list_by_database_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_database( self, resource_group_name: str, @@ -69,30 +74,19 @@ async def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +100,11 @@ async def list_by_database( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -137,29 +134,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,8 +160,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -207,34 +197,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Advisor') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Advisor') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -248,4 +228,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py index 8eb70c691507d..83f99cb942353 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_automatic_tuning_operations import build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,28 +71,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +96,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -132,33 +130,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseAutomaticTuning') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseAutomaticTuning') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -172,4 +160,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py index 33b9c177300b6..b30633c970b9b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_blob_auditing_policies_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,30 +73,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -135,35 +132,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseBlobAuditingPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,8 +166,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -200,8 +188,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseBlobAuditingPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicyListResult] + :return: An iterator like instance of either DatabaseBlobAuditingPolicyListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseBlobAuditingPolicyListResult"] @@ -209,37 +199,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("DatabaseBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -257,6 +245,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_columns_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_columns_operations.py index 94b1c1f69730e..6cca74cb693de 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_columns_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_columns_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_columns_operations import build_get_request, build_list_by_database_request, build_list_by_table_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -73,8 +79,10 @@ def list_by_database( :param skiptoken: An opaque token that identifies a starting point in the collection. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseColumnListResult"] @@ -82,47 +90,45 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if schema is not None: - query_parameters['schema'] = [self._serialize.query("schema", q, 'str') if q is not None else '' for q in schema] - if table is not None: - query_parameters['table'] = [self._serialize.query("table", q, 'str') if q is not None else '' for q in table] - if column is not None: - query_parameters['column'] = [self._serialize.query("column", q, 'str') if q is not None else '' for q in column] - if order_by is not None: - query_parameters['orderBy'] = [self._serialize.query("order_by", q, 'str') if q is not None else '' for q in order_by] - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -140,11 +146,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/columns'} # type: ignore + @distributed_trace def list_by_table( self, resource_group_name: str, @@ -171,8 +179,10 @@ def list_by_table( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseColumnListResult"] @@ -180,41 +190,41 @@ def list_by_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_table.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -232,11 +242,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -272,31 +284,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -310,4 +312,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py index 5db4dfa3a914a..7a32fc9c2d9c7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._database_extensions_operations import build_create_or_update_request_initial, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,27 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,6 +103,7 @@ async def get( get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,34 +118,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseExtensions') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseExtensions') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +151,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -188,15 +180,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions :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. + :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 ImportExportExtensionsOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ImportExportExtensionsOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportExtensionsOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -210,29 +207,21 @@ async def begin_create_or_update( database_name=database_name, extension_name=extension_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportExtensionsOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -244,8 +233,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -263,8 +254,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportExportExtensionsOperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationListResult] + :return: An iterator like instance of either ImportExportExtensionsOperationListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportExtensionsOperationListResult"] @@ -272,37 +265,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ImportExportExtensionsOperationListResult', pipeline_response) + deserialized = self._deserialize("ImportExportExtensionsOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -320,6 +311,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_operations_operations.py index 22a293e833362..f1c0ea57c26b8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_operations_operations import build_cancel_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -70,27 +76,19 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,6 +101,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -120,8 +120,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseOperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseOperationListResult] + :return: An iterator like instance of either DatabaseOperationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseOperationListResult"] @@ -129,37 +131,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseOperationListResult', pipeline_response) + deserialized = self._deserialize("DatabaseOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +177,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_recommended_actions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_recommended_actions_operations.py index d7aff2a9e759e..c6202cf6e9e4e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_recommended_actions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_recommended_actions_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_recommended_actions_operations import build_get_request, build_list_by_database_advisor_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_database_advisor( self, resource_group_name: str, @@ -69,29 +74,19 @@ async def list_by_database_advisor( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_database_advisor.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_database_advisor_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database_advisor.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +100,11 @@ async def list_by_database_advisor( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_database_advisor.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -139,30 +137,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'recommendedActionName': self._serialize.url("recommended_action_name", recommended_action_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,8 +164,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -213,35 +204,25 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'recommendedActionName': self._serialize.url("recommended_action_name", recommended_action_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'RecommendedAction') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecommendedAction') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -255,4 +236,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py index f22f12ff4a7ed..80dd014e06818 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_schemas_operations import build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -61,8 +67,10 @@ def list_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseSchemaListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchemaListResult] + :return: An iterator like instance of either DatabaseSchemaListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchemaListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseSchemaListResult"] @@ -70,39 +78,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseSchemaListResult', pipeline_response) + deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,11 +126,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -154,29 +162,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -190,4 +188,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py index c79e48ea5a248..45a412e888f89 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_security_alert_policies_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -70,29 +76,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +102,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -140,34 +139,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseSecurityAlertPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +174,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -204,8 +196,10 @@ def list_by_database( :param database_name: The name of the database for which the security alert policy is defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseSecurityAlertListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertListResult] + :return: An iterator like instance of either DatabaseSecurityAlertListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseSecurityAlertListResult"] @@ -213,37 +207,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseSecurityAlertListResult', pipeline_response) + deserialized = self._deserialize("DatabaseSecurityAlertListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -261,6 +253,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_tables_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_tables_operations.py index cb53f2d2f1ea1..1c56110e97762 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_tables_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_tables_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_tables_operations import build_get_request, build_list_by_schema_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_schema( self, resource_group_name: str, @@ -64,7 +70,8 @@ def list_by_schema( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseTableListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseTableListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseTableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -73,40 +80,39 @@ def list_by_schema( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_schema.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_schema.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseTableListResult', pipeline_response) + deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,11 +130,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -161,30 +169,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -198,4 +196,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py index aa2f2403dd9ed..275877cdebf14 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_usages_operations import build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -58,7 +64,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseUsageListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseUsageListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseUsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -67,37 +74,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseUsageListResult', pipeline_response) + deserialized = self._deserialize("DatabaseUsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,6 +120,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py index 78de5105ff33f..72eeef228b1dc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_vulnerability_assessment_rule_baselines_operations import build_create_or_update_request, build_delete_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -77,31 +82,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -115,8 +110,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -157,36 +155,26 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -200,8 +188,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -239,29 +230,21 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,3 +256,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py index c62e3efa4941e..1155ad1aeaf33 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._database_vulnerability_assessment_scans_operations import build_export_request, build_get_request, build_initiate_scan_request_initial, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,28 +62,20 @@ async def _initiate_scan_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._initiate_scan_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_initiate_scan_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self._initiate_scan_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +88,8 @@ async def _initiate_scan_initial( _initiate_scan_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + + @distributed_trace_async async def begin_initiate_scan( self, resource_group_name: str, @@ -115,15 +114,17 @@ async def begin_initiate_scan( :type scan_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -140,24 +141,14 @@ async def begin_initiate_scan( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -169,8 +160,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_initiate_scan.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -191,8 +184,10 @@ def list_by_database( :param vulnerability_assessment_name: The name of the vulnerability assessment. :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] + :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecordListResult"] @@ -200,38 +195,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VulnerabilityAssessmentScanRecordListResult', pipeline_response) + deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -249,11 +243,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -286,30 +282,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -323,8 +309,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}'} # type: ignore + + @distributed_trace_async async def export( self, resource_group_name: str, @@ -357,30 +346,20 @@ async def export( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.export.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.export.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -398,4 +377,6 @@ async def export( return cls(pipeline_response, deserialized, {}) return deserialized + export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py index d415122f64d21..a85ecbf59421e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_vulnerability_assessments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -71,29 +77,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,8 +103,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -142,34 +141,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,8 +176,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -219,27 +211,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -252,6 +236,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -270,8 +256,10 @@ def list_by_database( are defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] + :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseVulnerabilityAssessmentListResult"] @@ -279,37 +267,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -327,6 +313,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py index 554db3b46751f..76f80ba8e3302 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._databases_operations import build_create_or_update_request_initial, build_delete_request_initial, build_export_request_initial, build_failover_request_initial, build_get_request, build_import_method_request_initial, build_list_by_elastic_pool_request, build_list_by_server_request, build_list_inaccessible_by_server_request, build_list_metric_definitions_request, build_list_metrics_request, build_pause_request_initial, build_rename_request, build_resume_request_initial, build_update_request_initial, build_upgrade_data_warehouse_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -72,38 +78,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,11 +126,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics'} # type: ignore + @distributed_trace def list_metric_definitions( self, resource_group_name: str, @@ -143,8 +150,10 @@ def list_metric_definitions( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinitionListResult] + :return: An iterator like instance of either MetricDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionListResult"] @@ -152,37 +161,35 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MetricDefinitionListResult', pipeline_response) + deserialized = self._deserialize("MetricDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -200,11 +207,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metric_definitions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -231,38 +240,35 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseListResult', pipeline_response) + deserialized = self._deserialize("DatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -280,11 +286,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -311,28 +319,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -346,8 +344,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -361,33 +361,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Database') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Database') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -406,8 +396,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -429,15 +422,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.Database :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. + :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 Database or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -450,28 +447,21 @@ async def begin_create_or_update( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -483,6 +473,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore async def _delete_initial( @@ -497,26 +488,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -529,6 +512,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -547,15 +532,17 @@ async def begin_delete( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -570,22 +557,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -597,6 +576,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore async def _update_initial( @@ -612,33 +592,23 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -654,8 +624,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -677,15 +650,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate :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. + :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 Database or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -698,28 +675,21 @@ async def begin_update( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -731,8 +701,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + @distributed_trace def list_by_elastic_pool( self, resource_group_name: str, @@ -759,37 +731,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseListResult', pipeline_response) + deserialized = self._deserialize("DatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -807,6 +777,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -825,28 +796,19 @@ async def _failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if replica_type is not None: - query_parameters['replicaType'] = self._serialize.query("replica_type", replica_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -859,6 +821,8 @@ async def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore + + @distributed_trace_async async def begin_failover( self, resource_group_name: str, @@ -880,15 +844,17 @@ async def begin_failover( :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -904,22 +870,14 @@ async def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -931,8 +889,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore + @distributed_trace def list_inaccessible_by_server( self, resource_group_name: str, @@ -956,36 +916,33 @@ def list_inaccessible_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_inaccessible_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_inaccessible_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseListResult', pipeline_response) + deserialized = self._deserialize("DatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1003,6 +960,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1020,28 +978,18 @@ async def _pause_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._pause_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_pause_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._pause_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1057,8 +1005,11 @@ async def _pause_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _pause_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore + + @distributed_trace_async async def begin_pause( self, resource_group_name: str, @@ -1077,15 +1028,18 @@ async def begin_pause( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 Database or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -1100,25 +1054,17 @@ async def begin_pause( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1130,6 +1076,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_pause.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore async def _resume_initial( @@ -1144,28 +1091,18 @@ async def _resume_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._resume_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_resume_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._resume_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1181,8 +1118,11 @@ async def _resume_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore + + @distributed_trace_async async def begin_resume( self, resource_group_name: str, @@ -1201,15 +1141,18 @@ async def begin_resume( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 Database or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -1224,25 +1167,17 @@ async def begin_resume( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1254,6 +1189,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore async def _upgrade_data_warehouse_initial( @@ -1268,26 +1204,18 @@ async def _upgrade_data_warehouse_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._upgrade_data_warehouse_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_upgrade_data_warehouse_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._upgrade_data_warehouse_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1300,6 +1228,8 @@ async def _upgrade_data_warehouse_initial( _upgrade_data_warehouse_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + + @distributed_trace_async async def begin_upgrade_data_warehouse( self, resource_group_name: str, @@ -1318,15 +1248,17 @@ async def begin_upgrade_data_warehouse( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1341,22 +1273,14 @@ async def begin_upgrade_data_warehouse( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1368,8 +1292,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_upgrade_data_warehouse.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + @distributed_trace_async async def rename( self, resource_group_name: str, @@ -1399,31 +1325,23 @@ async def rename( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.rename.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceMoveDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_rename_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.rename.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceMoveDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1436,6 +1354,7 @@ async def rename( rename.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move'} # type: ignore + async def _import_method_initial( self, resource_group_name: str, @@ -1449,33 +1368,23 @@ async def _import_method_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._import_method_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_import_method_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._import_method_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1491,8 +1400,11 @@ async def _import_method_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore + + @distributed_trace_async async def begin_import_method( self, resource_group_name: str, @@ -1514,15 +1426,19 @@ async def begin_import_method( :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 ImportExportOperationResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1535,28 +1451,21 @@ async def begin_import_method( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1568,6 +1477,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore async def _export_initial( @@ -1583,33 +1493,23 @@ async def _export_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ExportDatabaseDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._export_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportDatabaseDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1625,8 +1525,11 @@ async def _export_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore + + @distributed_trace_async async def begin_export( self, resource_group_name: str, @@ -1648,15 +1551,19 @@ async def begin_export( :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 ImportExportOperationResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1669,28 +1576,21 @@ async def begin_export( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1702,4 +1602,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_deleted_servers_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_deleted_servers_operations.py index 633be0cdf164f..aa9edb23269ca 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_deleted_servers_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_deleted_servers_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._deleted_servers_operations import build_get_request, build_list_by_location_request, build_list_request, build_recover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -50,7 +56,8 @@ def list( """Gets a list of all deleted servers in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedServerListResult or the result of cls(response) + :return: An iterator like instance of either DeletedServerListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DeletedServerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -59,34 +66,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeletedServerListResult', pipeline_response) + deserialized = self._deserialize("DeletedServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,11 +106,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers'} # type: ignore + @distributed_trace_async async def get( self, location_name: str, @@ -131,27 +135,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'deletedServerName': self._serialize.url("deleted_server_name", deleted_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,8 +159,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}'} # type: ignore + + @distributed_trace def list_by_location( self, location_name: str, @@ -177,7 +174,8 @@ def list_by_location( :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedServerListResult or the result of cls(response) + :return: An iterator like instance of either DeletedServerListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DeletedServerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -186,35 +184,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeletedServerListResult', pipeline_response) + deserialized = self._deserialize("DeletedServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -232,6 +226,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -248,27 +243,17 @@ async def _recover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._recover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'deletedServerName': self._serialize.url("deleted_server_name", deleted_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_recover_request_initial( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + template_url=self._recover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -284,8 +269,11 @@ async def _recover_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _recover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover'} # type: ignore + + @distributed_trace_async async def begin_recover( self, location_name: str, @@ -300,15 +288,18 @@ async def begin_recover( :type deleted_server_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 DeletedServer or the result of cls(response) + :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 DeletedServer or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServer"] lro_delay = kwargs.pop( 'polling_interval', @@ -322,24 +313,17 @@ async def begin_recover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeletedServer', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'deletedServerName': self._serialize.url("deleted_server_name", deleted_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -351,4 +335,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_recover.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py index 8e0b99ff8f2d4..fbd4a017f760b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._elastic_pool_activities_operations import build_list_by_elastic_pool_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_elastic_pool( self, resource_group_name: str, @@ -58,8 +64,10 @@ def list_by_elastic_pool( :param elastic_pool_name: The name of the elastic pool for which to get the current activity. :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolActivityListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolActivityListResult] + :return: An iterator like instance of either ElasticPoolActivityListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPoolActivityListResult"] @@ -67,37 +75,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolActivityListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolActivityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,6 +121,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py index 45411c0456573..0acf7ab8ec96f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._elastic_pool_database_activities_operations import build_list_by_elastic_pool_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_elastic_pool( self, resource_group_name: str, @@ -58,8 +64,10 @@ def list_by_elastic_pool( :param elastic_pool_name: The name of the elastic pool. :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolDatabaseActivityListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivityListResult] + :return: An iterator like instance of either ElasticPoolDatabaseActivityListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPoolDatabaseActivityListResult"] @@ -67,37 +75,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolDatabaseActivityListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolDatabaseActivityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,6 +121,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_operations_operations.py index d4cbc9f67fb88..117eae37221a0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._elastic_pool_operations_operations import build_cancel_request, build_list_by_elastic_pool_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -70,27 +76,19 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,6 +101,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel'} # type: ignore + + @distributed_trace def list_by_elastic_pool( self, resource_group_name: str, @@ -120,8 +120,10 @@ def list_by_elastic_pool( :param elastic_pool_name: :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolOperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolOperationListResult] + :return: An iterator like instance of either ElasticPoolOperationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPoolOperationListResult"] @@ -129,37 +131,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolOperationListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +177,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py index 65df2d9b28dee..bd2823e91f765 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._elastic_pools_operations import build_create_or_update_request_initial, build_delete_request_initial, build_failover_request_initial, build_get_request, build_list_by_server_request, build_list_metric_definitions_request, build_list_metrics_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -72,38 +78,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,11 +126,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics'} # type: ignore + @distributed_trace def list_metric_definitions( self, resource_group_name: str, @@ -143,8 +150,10 @@ def list_metric_definitions( :param elastic_pool_name: The name of the elastic pool. :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinitionListResult] + :return: An iterator like instance of either MetricDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionListResult"] @@ -152,37 +161,35 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MetricDefinitionListResult', pipeline_response) + deserialized = self._deserialize("MetricDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -200,11 +207,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metric_definitions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -222,7 +231,8 @@ def list_by_server( :param skip: The number of elements in the collection to skip. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolListResult or the result of cls(response) + :return: An iterator like instance of either ElasticPoolListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -231,38 +241,35 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip=skip, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip=skip, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -280,11 +287,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -311,28 +320,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -346,8 +345,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -361,33 +362,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ElasticPool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ElasticPool') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -406,8 +397,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -429,15 +423,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ElasticPool :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. + :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 ElasticPool or the result of cls(response) + :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 ElasticPool or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPool"] lro_delay = kwargs.pop( 'polling_interval', @@ -450,28 +448,21 @@ async def begin_create_or_update( server_name=server_name, elastic_pool_name=elastic_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ElasticPool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -483,6 +474,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore async def _delete_initial( @@ -497,26 +489,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -529,6 +513,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -547,15 +533,17 @@ async def begin_delete( :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -570,22 +558,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -597,6 +577,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore async def _update_initial( @@ -612,33 +593,23 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ElasticPoolUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ElasticPoolUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -654,8 +625,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -677,15 +651,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate :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. + :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 ElasticPool or the result of cls(response) + :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 ElasticPool or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPool"] lro_delay = kwargs.pop( 'polling_interval', @@ -698,28 +676,21 @@ async def begin_update( server_name=server_name, elastic_pool_name=elastic_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ElasticPool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -731,6 +702,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore async def _failover_initial( @@ -745,26 +717,18 @@ async def _failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -777,6 +741,8 @@ async def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover'} # type: ignore + + @distributed_trace_async async def begin_failover( self, resource_group_name: str, @@ -795,15 +761,17 @@ async def begin_failover( :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -818,22 +786,14 @@ async def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -845,4 +805,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py index 11a3f470d2b37..61d9ef416bbf5 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._encryption_protectors_operations import build_create_or_update_request_initial, build_get_request, build_list_by_server_request, build_revalidate_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EncryptionProtectorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.EncryptionProtectorListResult] + :return: An iterator like instance of either EncryptionProtectorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.EncryptionProtectorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtectorListResult"] @@ -66,36 +74,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EncryptionProtectorListResult', pipeline_response) + deserialized = self._deserialize("EncryptionProtectorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +118,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,28 +151,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +176,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -194,33 +193,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'EncryptionProtector') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'EncryptionProtector') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -236,8 +225,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -259,15 +251,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.EncryptionProtector :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. + :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 EncryptionProtector or the result of cls(response) + :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 EncryptionProtector or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtector"] lro_delay = kwargs.pop( 'polling_interval', @@ -280,28 +276,21 @@ async def begin_create_or_update( server_name=server_name, encryption_protector_name=encryption_protector_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('EncryptionProtector', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -313,6 +302,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore async def _revalidate_initial( @@ -327,26 +317,18 @@ async def _revalidate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._revalidate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_revalidate_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self._revalidate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -359,6 +341,8 @@ async def _revalidate_initial( _revalidate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore + + @distributed_trace_async async def begin_revalidate( self, resource_group_name: str, @@ -377,15 +361,17 @@ async def begin_revalidate( :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,22 +386,14 @@ async def begin_revalidate( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -427,4 +405,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_revalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py index 8763173c9bc6e..217f826120f8a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._extended_database_blob_auditing_policies_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,30 +73,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -135,35 +132,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExtendedDatabaseBlobAuditingPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExtendedDatabaseBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,8 +166,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -200,8 +188,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedDatabaseBlobAuditingPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicyListResult] + :return: An iterator like instance of either ExtendedDatabaseBlobAuditingPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedDatabaseBlobAuditingPolicyListResult"] @@ -209,37 +199,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ExtendedDatabaseBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("ExtendedDatabaseBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -257,6 +245,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_server_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_server_blob_auditing_policies_operations.py index 986cc05891974..026def18dff50 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_server_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_server_blob_auditing_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._extended_server_blob_auditing_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,29 +72,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +96,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -116,34 +112,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ExtendedServerBlobAuditingPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExtendedServerBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,8 +143,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -179,15 +166,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy :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. + :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 ExtendedServerBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ExtendedServerBlobAuditingPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -199,29 +191,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ExtendedServerBlobAuditingPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - blob_auditing_policy_name = "default" - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -233,8 +217,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -249,8 +235,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedServerBlobAuditingPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicyListResult] + :return: An iterator like instance of either ExtendedServerBlobAuditingPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicyListResult"] @@ -258,36 +246,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ExtendedServerBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -305,6 +290,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_failover_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_failover_groups_operations.py index 9d1e9e8a938d8..910b2bd8d06f5 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_failover_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_failover_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._failover_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_failover_request_initial, build_force_failover_allow_data_loss_request_initial, build_get_request, build_list_by_server_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FailoverGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FailoverGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -187,15 +178,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.FailoverGroup :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. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,28 +203,21 @@ async def begin_create_or_update( server_name=server_name, failover_group_name=failover_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -241,6 +229,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore async def _delete_initial( @@ -255,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -305,15 +288,17 @@ async def begin_delete( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,22 +313,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -355,6 +332,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore async def _update_initial( @@ -370,33 +348,23 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'FailoverGroupUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FailoverGroupUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -412,8 +380,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -435,15 +406,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate :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. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -456,28 +431,21 @@ async def begin_update( server_name=server_name, failover_group_name=failover_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -489,8 +457,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -505,7 +475,8 @@ def list_by_server( :param server_name: The name of the server containing the failover group. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FailoverGroupListResult or the result of cls(response) + :return: An iterator like instance of either FailoverGroupListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FailoverGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -514,36 +485,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('FailoverGroupListResult', pipeline_response) + deserialized = self._deserialize("FailoverGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -561,6 +529,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -578,28 +547,18 @@ async def _failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -615,8 +574,11 @@ async def _failover_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover'} # type: ignore + + @distributed_trace_async async def begin_failover( self, resource_group_name: str, @@ -635,15 +597,18 @@ async def begin_failover( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -658,25 +623,17 @@ async def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -688,6 +645,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover'} # type: ignore async def _force_failover_allow_data_loss_initial( @@ -702,28 +660,18 @@ async def _force_failover_allow_data_loss_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._force_failover_allow_data_loss_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_force_failover_allow_data_loss_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._force_failover_allow_data_loss_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -739,8 +687,11 @@ async def _force_failover_allow_data_loss_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _force_failover_allow_data_loss_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore + + @distributed_trace_async async def begin_force_failover_allow_data_loss( self, resource_group_name: str, @@ -760,15 +711,18 @@ async def begin_force_failover_allow_data_loss( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -783,25 +737,17 @@ async def begin_force_failover_allow_data_loss( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -813,4 +759,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_force_failover_allow_data_loss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py index dec3e17846340..83e54219c5ff3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._firewall_rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_server_request, build_replace_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,28 +73,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -133,33 +132,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FirewallRule') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FirewallRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,8 +166,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -205,26 +197,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -237,6 +221,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -251,7 +237,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FirewallRuleListResult or the result of cls(response) + :return: An iterator like instance of either FirewallRuleListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FirewallRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -260,36 +247,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('FirewallRuleListResult', pipeline_response) + deserialized = self._deserialize("FirewallRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -307,11 +291,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules'} # type: ignore + @distributed_trace_async async def replace( self, resource_group_name: str, @@ -338,32 +324,22 @@ async def replace( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.replace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FirewallRuleList') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_replace_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.replace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FirewallRuleList') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,4 +355,6 @@ async def replace( return cls(pipeline_response, deserialized, {}) return deserialized + replace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py index c9658887d30ff..9ca4d19e25fee 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._geo_backup_policies_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -73,34 +79,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'geoBackupPolicyName': self._serialize.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'GeoBackupPolicy') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + geo_backup_policy_name=geo_backup_policy_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GeoBackupPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -118,8 +114,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,29 +148,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'geoBackupPolicyName': self._serialize.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + geo_backup_policy_name=geo_backup_policy_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +174,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -204,8 +196,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GeoBackupPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.GeoBackupPolicyListResult] + :return: An iterator like instance of either GeoBackupPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.GeoBackupPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GeoBackupPolicyListResult"] @@ -213,37 +207,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GeoBackupPolicyListResult', pipeline_response) + deserialized = self._deserialize("GeoBackupPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -261,6 +253,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_failover_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_failover_groups_operations.py index 16b61635b48b1..11c30e3677aeb 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_failover_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_failover_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._instance_failover_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_failover_request_initial, build_force_failover_allow_data_loss_request_initial, build_get_request, build_list_by_location_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'InstanceFailoverGroup') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InstanceFailoverGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -187,15 +178,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup :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. + :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 InstanceFailoverGroup or the result of cls(response) + :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 InstanceFailoverGroup or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceFailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,28 +203,21 @@ async def begin_create_or_update( location_name=location_name, failover_group_name=failover_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstanceFailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -241,6 +229,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore async def _delete_initial( @@ -255,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -305,15 +288,17 @@ async def begin_delete( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,22 +313,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -355,8 +332,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + @distributed_trace def list_by_location( self, resource_group_name: str, @@ -371,8 +350,10 @@ def list_by_location( :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstanceFailoverGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstanceFailoverGroupListResult] + :return: An iterator like instance of either InstanceFailoverGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstanceFailoverGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceFailoverGroupListResult"] @@ -380,36 +361,33 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InstanceFailoverGroupListResult', pipeline_response) + deserialized = self._deserialize("InstanceFailoverGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,6 +405,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -444,28 +423,18 @@ async def _failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -481,8 +450,11 @@ async def _failover_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover'} # type: ignore + + @distributed_trace_async async def begin_failover( self, resource_group_name: str, @@ -501,15 +473,18 @@ async def begin_failover( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 InstanceFailoverGroup or the result of cls(response) + :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 InstanceFailoverGroup or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceFailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -524,25 +499,17 @@ async def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstanceFailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -554,6 +521,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover'} # type: ignore async def _force_failover_allow_data_loss_initial( @@ -568,28 +536,18 @@ async def _force_failover_allow_data_loss_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._force_failover_allow_data_loss_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_force_failover_allow_data_loss_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._force_failover_allow_data_loss_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -605,8 +563,11 @@ async def _force_failover_allow_data_loss_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _force_failover_allow_data_loss_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore + + @distributed_trace_async async def begin_force_failover_allow_data_loss( self, resource_group_name: str, @@ -626,15 +587,18 @@ async def begin_force_failover_allow_data_loss( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 InstanceFailoverGroup or the result of cls(response) + :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 InstanceFailoverGroup or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceFailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -649,25 +613,17 @@ async def begin_force_failover_allow_data_loss( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstanceFailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -679,4 +635,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_force_failover_allow_data_loss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py index 37899619d6158..373a8a5217a35 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._instance_pools_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,27 +72,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -114,32 +112,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InstancePool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InstancePool') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,8 +146,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -178,15 +169,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.InstancePool :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. + :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 InstancePool or the result of cls(response) + :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 InstancePool or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstancePool"] lro_delay = kwargs.pop( 'polling_interval', @@ -198,27 +193,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, instance_pool_name=instance_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstancePool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -230,6 +219,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore async def _delete_initial( @@ -243,25 +233,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,6 +256,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -289,15 +273,17 @@ async def begin_delete( :type instance_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -311,21 +297,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -337,6 +316,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore async def _update_initial( @@ -351,32 +331,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InstancePoolUpdate') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InstancePoolUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -392,8 +362,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -412,15 +385,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate :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. + :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 InstancePool or the result of cls(response) + :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 InstancePool or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstancePool"] lro_delay = kwargs.pop( 'polling_interval', @@ -432,27 +409,21 @@ async def begin_update( resource_group_name=resource_group_name, instance_pool_name=instance_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstancePool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -464,8 +435,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -477,7 +450,8 @@ def list_by_resource_group( obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstancePoolListResult or the result of cls(response) + :return: An iterator like instance of either InstancePoolListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePoolListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -486,35 +460,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InstancePoolListResult', pipeline_response) + deserialized = self._deserialize("InstancePoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -532,11 +502,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -544,7 +516,8 @@ def list( """Gets a list of all instance pools in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstancePoolListResult or the result of cls(response) + :return: An iterator like instance of either InstancePoolListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePoolListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -553,34 +526,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InstancePoolListResult', pipeline_response) + deserialized = self._deserialize("InstancePoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -598,6 +566,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ipv6_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ipv6_firewall_rules_operations.py new file mode 100644 index 0000000000000..e56ca7ce3bb37 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ipv6_firewall_rules_operations.py @@ -0,0 +1,299 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._ipv6_firewall_rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_server_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class IPv6FirewallRulesOperations: + """IPv6FirewallRulesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sql.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> "_models.IPv6FirewallRule": + """Gets an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IPv6FirewallRule, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.IPv6FirewallRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('IPv6FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: "_models.IPv6FirewallRule", + **kwargs: Any + ) -> "_models.IPv6FirewallRule": + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating an IPv6 firewall rule. + :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IPv6FirewallRule, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.IPv6FirewallRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IPv6FirewallRule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 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('IPv6FirewallRule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('IPv6FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def list_by_server( + self, + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.IPv6FirewallRuleListResult"]: + """Gets a list of IPv6 firewall rules. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IPv6FirewallRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.IPv6FirewallRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.IPv6FirewallRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IPv6FirewallRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py index f4496a17fd128..ea450e5556b71 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._job_agents_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -66,36 +72,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobAgentListResult', pipeline_response) + deserialized = self._deserialize("JobAgentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +174,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -194,33 +191,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'JobAgent') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobAgent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -239,8 +226,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -262,15 +252,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.JobAgent :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. + :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 JobAgent or the result of cls(response) + :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 JobAgent or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -283,28 +277,21 @@ async def begin_create_or_update( server_name=server_name, job_agent_name=job_agent_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -316,6 +303,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore async def _delete_initial( @@ -330,26 +318,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -362,6 +342,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -380,15 +362,17 @@ async def begin_delete( :type job_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -403,22 +387,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -430,6 +406,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore async def _update_initial( @@ -445,33 +422,23 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'JobAgentUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobAgentUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -487,8 +454,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -510,15 +480,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate :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. + :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 JobAgent or the result of cls(response) + :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 JobAgent or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -531,28 +505,21 @@ async def begin_update( server_name=server_name, job_agent_name=job_agent_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -564,4 +531,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py index 2e5bf3afc1746..8409e392980b4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_credentials_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_agent_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, resource_group_name: str, @@ -58,7 +64,8 @@ def list_by_agent( :param job_agent_name: The name of the job agent. :type job_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobCredentialListResult or the result of cls(response) + :return: An iterator like instance of either JobCredentialListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobCredentialListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -67,37 +74,35 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobCredentialListResult', pipeline_response) + deserialized = self._deserialize("JobCredentialListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,11 +120,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,29 +156,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +182,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -219,34 +219,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'JobCredential') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -264,8 +254,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -295,27 +288,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -327,3 +312,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py index 9e38dee4f59c8..7831f68b69b5a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py @@ -6,19 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._job_executions_operations import build_cancel_request, build_create_or_update_request_initial, build_create_request_initial, build_get_request, build_list_by_agent_request, build_list_by_job_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,6 +49,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, resource_group_name: str, @@ -86,7 +92,8 @@ def list_by_agent( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -95,51 +102,49 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -157,11 +162,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions'} # type: ignore + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -194,28 +201,20 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -228,6 +227,7 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel'} # type: ignore + async def _create_initial( self, resource_group_name: str, @@ -241,29 +241,19 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -279,8 +269,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -302,15 +295,18 @@ async def begin_create( :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 JobExecution or the result of cls(response) + :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 JobExecution or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobExecution"] lro_delay = kwargs.pop( 'polling_interval', @@ -326,26 +322,17 @@ async def begin_create( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobExecution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -357,8 +344,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start'} # type: ignore + @distributed_trace def list_by_job( self, resource_group_name: str, @@ -404,7 +393,8 @@ def list_by_job( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -413,52 +403,51 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -476,11 +465,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -513,30 +504,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -550,8 +531,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -566,30 +549,20 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -608,8 +581,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -634,15 +610,18 @@ async def begin_create_or_update( :type job_execution_id: 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. + :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 JobExecution or the result of cls(response) + :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 JobExecution or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobExecution"] lro_delay = kwargs.pop( 'polling_interval', @@ -659,27 +638,17 @@ async def begin_create_or_update( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobExecution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -691,4 +660,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py index 02412a6b6e318..f0fc02b02e5ed 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py @@ -6,17 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_step_executions_operations import build_get_request, build_list_by_job_execution_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_job_execution( self, resource_group_name: str, @@ -90,7 +96,8 @@ def list_by_job_execution( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -99,53 +106,53 @@ def list_by_job_execution( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job_execution.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_job_execution.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -163,11 +170,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_job_execution.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -203,31 +212,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -241,4 +240,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py index fa4c2e6127b93..ed926ae2f1829 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_steps_operations import build_create_or_update_request, build_delete_request, build_get_by_version_request, build_get_request, build_list_by_job_request, build_list_by_version_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_version( self, resource_group_name: str, @@ -73,39 +79,39 @@ def list_by_version( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_version.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobVersion': self._serialize.url("job_version", job_version, 'int'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_version_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + template_url=self.list_by_version.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_version_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobStepListResult', pipeline_response) + deserialized = self._deserialize("JobStepListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,11 +129,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_version.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps'} # type: ignore + @distributed_trace_async async def get_by_version( self, resource_group_name: str, @@ -163,31 +171,21 @@ async def get_by_version( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_version.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobVersion': self._serialize.url("job_version", job_version, 'int'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_version_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_version.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,8 +199,11 @@ async def get_by_version( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_version.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}'} # type: ignore + + @distributed_trace def list_by_job( self, resource_group_name: str, @@ -232,38 +233,37 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobStepListResult', pipeline_response) + deserialized = self._deserialize("JobStepListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -281,11 +281,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -318,30 +320,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -355,8 +347,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -392,35 +387,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'JobStep') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobStep') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -438,8 +423,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -472,28 +460,20 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -505,3 +485,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py index a11ea1d169539..d182423a21c44 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py @@ -6,17 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_target_executions_operations import build_get_request, build_list_by_job_execution_request, build_list_by_step_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_job_execution( self, resource_group_name: str, @@ -90,7 +96,8 @@ def list_by_job_execution( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -99,53 +106,53 @@ def list_by_job_execution( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job_execution.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_job_execution.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -163,11 +170,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_job_execution.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets'} # type: ignore + @distributed_trace def list_by_step( self, resource_group_name: str, @@ -219,7 +228,8 @@ def list_by_step( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -228,54 +238,55 @@ def list_by_step( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_step.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_step_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_step.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_step_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -293,11 +304,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_step.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -336,32 +349,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'targetId': self._serialize.url("target_id", target_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + target_id=target_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -375,4 +378,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py index ebd4db5b35379..cab2b0ab243a3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_target_groups_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_agent_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, resource_group_name: str, @@ -58,8 +64,10 @@ def list_by_agent( :param job_agent_name: The name of the job agent. :type job_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobTargetGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobTargetGroupListResult] + :return: An iterator like instance of either JobTargetGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobTargetGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobTargetGroupListResult"] @@ -67,37 +75,35 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobTargetGroupListResult', pipeline_response) + deserialized = self._deserialize("JobTargetGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,11 +121,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,29 +157,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'targetGroupName': self._serialize.url("target_group_name", target_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +183,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -219,34 +220,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'targetGroupName': self._serialize.url("target_group_name", target_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'JobTargetGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobTargetGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -264,8 +255,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -295,27 +289,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'targetGroupName': self._serialize.url("target_group_name", target_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -327,3 +313,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py index 7505a61990e93..fb2d48439d4ac 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_versions_operations import build_get_request, build_list_by_job_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_job( self, resource_group_name: str, @@ -61,7 +67,8 @@ def list_by_job( :param job_name: The name of the job to get. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobVersionListResult or the result of cls(response) + :return: An iterator like instance of either JobVersionListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobVersionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,38 +77,37 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobVersionListResult', pipeline_response) + deserialized = self._deserialize("JobVersionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -119,11 +125,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -156,30 +164,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobVersion': self._serialize.url("job_version", job_version, 'int'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -193,4 +191,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py index 16de26458be28..6aad73df03605 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_agent_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, resource_group_name: str, @@ -67,37 +73,35 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobListResult', pipeline_response) + deserialized = self._deserialize("JobListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,11 +119,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,29 +155,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +181,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -219,34 +218,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Job') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Job') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -264,8 +253,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -295,27 +287,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -327,3 +311,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py index 91146f4561885..84149da843604 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._ledger_digest_uploads_operations import build_create_or_update_request_initial, build_disable_request_initial, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,29 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -124,34 +122,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LedgerDigestUploads') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LedgerDigestUploads') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +155,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -194,15 +185,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] lro_delay = kwargs.pop( 'polling_interval', @@ -216,29 +211,21 @@ async def begin_create_or_update( database_name=database_name, ledger_digest_uploads=ledger_digest_uploads, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -250,8 +237,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -269,8 +258,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LedgerDigestUploadsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LedgerDigestUploadsListResult] + :return: An iterator like instance of either LedgerDigestUploadsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LedgerDigestUploadsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploadsListResult"] @@ -278,37 +269,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LedgerDigestUploadsListResult', pipeline_response) + deserialized = self._deserialize("LedgerDigestUploadsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -326,6 +315,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -344,29 +334,19 @@ async def _disable_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._disable_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_disable_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + template_url=self._disable_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -382,8 +362,11 @@ async def _disable_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _disable_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore + + @distributed_trace_async async def begin_disable( self, resource_group_name: str, @@ -406,15 +389,18 @@ async def begin_disable( :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] lro_delay = kwargs.pop( 'polling_interval', @@ -430,26 +416,17 @@ async def begin_disable( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -461,4 +438,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py index 3d47b1d465254..85a8d2ddf6ed7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._long_term_retention_backups_operations import build_copy_by_resource_group_request_initial, build_copy_request_initial, build_delete_by_resource_group_request_initial, build_delete_request_initial, build_get_by_resource_group_request, build_get_request, build_list_by_database_request, build_list_by_location_request, build_list_by_resource_group_database_request, build_list_by_resource_group_location_request, build_list_by_resource_group_server_request, build_list_by_server_request, build_update_by_resource_group_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,34 +62,24 @@ async def _copy_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._copy_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_copy_request_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._copy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +95,11 @@ async def _copy_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _copy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore + + @distributed_trace_async async def begin_copy( self, location_name: str, @@ -125,15 +123,20 @@ async def begin_copy( :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -147,29 +150,21 @@ async def begin_copy( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -181,6 +176,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_copy.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore async def _update_initial( @@ -197,34 +193,24 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -240,8 +226,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + + @distributed_trace_async async def begin_update( self, location_name: str, @@ -265,15 +254,20 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -287,29 +281,21 @@ async def begin_update( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -321,8 +307,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + @distributed_trace_async async def get( self, location_name: str, @@ -351,29 +339,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -387,8 +365,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + async def _delete_initial( self, location_name: str, @@ -402,27 +382,19 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -435,6 +407,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, location_name: str, @@ -455,15 +429,17 @@ async def begin_delete( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -479,23 +455,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -507,8 +474,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_database( self, location_name: str, @@ -533,8 +502,10 @@ def list_by_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupListResult"] @@ -542,41 +513,39 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -594,11 +563,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_location( self, location_name: str, @@ -617,8 +588,10 @@ def list_by_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupListResult"] @@ -626,39 +599,35 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -676,11 +645,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_server( self, location_name: str, @@ -702,8 +673,10 @@ def list_by_server( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupListResult"] @@ -711,40 +684,37 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -762,6 +732,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -782,35 +753,25 @@ async def _copy_by_resource_group_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._copy_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_copy_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._copy_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -826,8 +787,11 @@ async def _copy_by_resource_group_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _copy_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore + + @distributed_trace_async async def begin_copy_by_resource_group( self, resource_group_name: str, @@ -855,15 +819,20 @@ async def begin_copy_by_resource_group( :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -878,30 +847,21 @@ async def begin_copy_by_resource_group( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -913,6 +873,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_copy_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore async def _update_by_resource_group_initial( @@ -930,35 +891,25 @@ async def _update_by_resource_group_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') + + request = build_update_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -974,8 +925,11 @@ async def _update_by_resource_group_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + + @distributed_trace_async async def begin_update_by_resource_group( self, resource_group_name: str, @@ -1003,15 +957,20 @@ async def begin_update_by_resource_group( :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1026,30 +985,21 @@ async def begin_update_by_resource_group( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1061,8 +1011,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + @distributed_trace_async async def get_by_resource_group( self, resource_group_name: str, @@ -1095,30 +1047,20 @@ async def get_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1132,8 +1074,10 @@ async def get_by_resource_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + async def _delete_by_resource_group_initial( self, resource_group_name: str, @@ -1148,28 +1092,20 @@ async def _delete_by_resource_group_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1182,6 +1118,8 @@ async def _delete_by_resource_group_initial( _delete_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_resource_group( self, resource_group_name: str, @@ -1206,15 +1144,17 @@ async def begin_delete_by_resource_group( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1231,24 +1171,14 @@ async def begin_delete_by_resource_group( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1260,8 +1190,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_resource_group_database( self, resource_group_name: str, @@ -1290,8 +1222,10 @@ def list_by_resource_group_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupListResult"] @@ -1299,42 +1233,41 @@ def list_by_resource_group_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1352,11 +1285,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_resource_group_location( self, resource_group_name: str, @@ -1379,8 +1314,10 @@ def list_by_resource_group_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupListResult"] @@ -1388,40 +1325,37 @@ def list_by_resource_group_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1439,11 +1373,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_resource_group_server( self, resource_group_name: str, @@ -1469,8 +1405,10 @@ def list_by_resource_group_server( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupListResult"] @@ -1478,41 +1416,39 @@ def list_by_resource_group_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_server_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_server_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1530,6 +1466,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_managed_instance_backups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_managed_instance_backups_operations.py index 2365cf743737a..6e24d9dfc68ec 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_managed_instance_backups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_managed_instance_backups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._long_term_retention_managed_instance_backups_operations import build_delete_by_resource_group_request_initial, build_delete_request_initial, build_get_by_resource_group_request, build_get_request, build_list_by_database_request, build_list_by_instance_request, build_list_by_location_request, build_list_by_resource_group_database_request, build_list_by_resource_group_instance_request, build_list_by_resource_group_location_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, location_name: str, @@ -71,29 +77,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,8 +103,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + async def _delete_initial( self, location_name: str, @@ -122,27 +120,19 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -155,6 +145,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, location_name: str, @@ -175,15 +167,17 @@ async def begin_delete( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -199,23 +193,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -227,8 +212,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_database( self, location_name: str, @@ -253,8 +240,10 @@ def list_by_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -262,41 +251,39 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +301,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_instance( self, location_name: str, @@ -340,8 +329,10 @@ def list_by_instance( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -349,40 +340,37 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -400,11 +388,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_location( self, location_name: str, @@ -423,8 +413,10 @@ def list_by_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -432,39 +424,35 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -482,11 +470,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace_async async def get_by_resource_group( self, resource_group_name: str, @@ -519,30 +509,20 @@ async def get_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -556,8 +536,10 @@ async def get_by_resource_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + async def _delete_by_resource_group_initial( self, resource_group_name: str, @@ -572,28 +554,20 @@ async def _delete_by_resource_group_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -606,6 +580,8 @@ async def _delete_by_resource_group_initial( _delete_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_resource_group( self, resource_group_name: str, @@ -630,15 +606,17 @@ async def begin_delete_by_resource_group( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -655,24 +633,14 @@ async def begin_delete_by_resource_group( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -684,8 +652,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_resource_group_database( self, resource_group_name: str, @@ -714,8 +684,10 @@ def list_by_resource_group_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -723,42 +695,41 @@ def list_by_resource_group_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -776,11 +747,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_resource_group_instance( self, resource_group_name: str, @@ -806,8 +779,10 @@ def list_by_resource_group_instance( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -815,41 +790,39 @@ def list_by_resource_group_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_instance_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_instance_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -867,11 +840,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_resource_group_location( self, resource_group_name: str, @@ -894,8 +869,10 @@ def list_by_resource_group_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -903,40 +880,37 @@ def list_by_resource_group_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -954,6 +928,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py index 783890ed97c4d..61ae676c1232e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._long_term_retention_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,29 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -124,34 +122,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LongTermRetentionPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LongTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +155,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -193,15 +184,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy :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. + :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 LongTermRetentionPolicy or the result of cls(response) + :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 LongTermRetentionPolicy or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,29 +210,21 @@ async def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,8 +236,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -268,8 +257,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicyListResult] + :return: An iterator like instance of either LongTermRetentionPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionPolicyListResult"] @@ -277,37 +268,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -325,6 +314,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_window_options_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_window_options_operations.py index 5a9dee0afd723..0de8038f9d6e7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_window_options_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_window_options_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._maintenance_window_options_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,29 +74,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['maintenanceWindowOptionsName'] = self._serialize.query("maintenance_window_options_name", maintenance_window_options_name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_options_name=maintenance_window_options_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,4 +100,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindowOptions/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py index 2842e13dd4ce8..d32e9bb7ec38c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._maintenance_windows_operations import build_create_or_update_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,29 +74,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['maintenanceWindowName'] = self._serialize.query("maintenance_window_name", maintenance_window_name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_name=maintenance_window_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +100,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -139,32 +137,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['maintenanceWindowName'] = self._serialize.query("maintenance_window_name", maintenance_window_name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'MaintenanceWindows') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + maintenance_window_name=maintenance_window_name, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MaintenanceWindows') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,3 +166,4 @@ async def create_or_update( return cls(pipeline_response, None, {}) create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py index d01132145e035..e40310233afa6 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_backup_short_term_retention_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_database_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,29 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -124,34 +122,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +155,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -193,15 +184,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ManagedBackupShortTermRetentionPolicy or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,29 +211,21 @@ async def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,6 +237,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore async def _update_initial( @@ -265,34 +254,24 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,8 +287,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -334,15 +316,20 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ManagedBackupShortTermRetentionPolicy or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -356,29 +343,21 @@ async def begin_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -390,8 +369,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -409,8 +390,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] + :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicyListResult"] @@ -418,37 +401,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -466,6 +447,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_columns_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_columns_operations.py index 79e9ab4122e31..c91e6e11045d2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_columns_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_columns_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_columns_operations import build_get_request, build_list_by_database_request, build_list_by_table_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -73,8 +79,10 @@ def list_by_database( :param skiptoken: An opaque token that identifies a starting point in the collection. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseColumnListResult"] @@ -82,47 +90,45 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if schema is not None: - query_parameters['schema'] = [self._serialize.query("schema", q, 'str') if q is not None else '' for q in schema] - if table is not None: - query_parameters['table'] = [self._serialize.query("table", q, 'str') if q is not None else '' for q in table] - if column is not None: - query_parameters['column'] = [self._serialize.query("column", q, 'str') if q is not None else '' for q in column] - if order_by is not None: - query_parameters['orderBy'] = [self._serialize.query("order_by", q, 'str') if q is not None else '' for q in order_by] - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -140,11 +146,13 @@ async def get_next(next_link=None): 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}/columns'} # type: ignore + @distributed_trace def list_by_table( self, resource_group_name: str, @@ -171,8 +179,10 @@ def list_by_table( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseColumnListResult"] @@ -180,41 +190,41 @@ def list_by_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_table.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -232,11 +242,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -272,31 +284,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -310,4 +312,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py index 89d5e1bd25b5b..b90da2e4116af 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_queries_operations import build_get_request, build_list_by_query_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -70,29 +76,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'queryId': self._serialize.url("query_id", query_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +102,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}'} # type: ignore + + @distributed_trace def list_by_query( self, resource_group_name: str, @@ -137,8 +136,10 @@ def list_by_query( :param interval: The time step to be used to summarize the metric values. :type interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceQueryStatistics or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceQueryStatistics] + :return: An iterator like instance of either ManagedInstanceQueryStatistics or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceQueryStatistics] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceQueryStatistics"] @@ -146,44 +147,43 @@ def list_by_query( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_query.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'queryId': self._serialize.url("query_id", query_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - if end_time is not None: - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_query_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + interval=interval, + template_url=self.list_by_query.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_query_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + interval=interval, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceQueryStatistics', pipeline_response) + deserialized = self._deserialize("ManagedInstanceQueryStatistics", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -201,6 +201,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py index 198121b4ff90f..65f7f53da910c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_recommended_sensitivity_labels_operations import build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update( self, resource_group_name: str, @@ -69,31 +74,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') + + request = build_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,3 +102,4 @@ async def update( return cls(pipeline_response, None, {}) update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py index 44dd54646f974..1667c568480e3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_restore_details_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,29 +74,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'restoreDetailsName': self._serialize.url("restore_details_name", restore_details_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + restore_details_name=restore_details_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,4 +100,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py index abe0c3fb92112..0d3362d6f44c2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_schemas_operations import build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -61,8 +67,10 @@ def list_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseSchemaListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchemaListResult] + :return: An iterator like instance of either DatabaseSchemaListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchemaListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseSchemaListResult"] @@ -70,39 +78,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseSchemaListResult', pipeline_response) + deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,11 +126,13 @@ async def get_next(next_link=None): 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}/schemas'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -154,29 +162,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -190,4 +188,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py index a8594bd75a361..cfc598e7d4adf 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_security_alert_policies_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -71,29 +77,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,8 +103,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -142,34 +141,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedDatabaseSecurityAlertPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedDatabaseSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,8 +176,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -207,8 +199,10 @@ def list_by_database( are defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedDatabaseSecurityAlertPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicyListResult] + :return: An iterator like instance of either ManagedDatabaseSecurityAlertPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabaseSecurityAlertPolicyListResult"] @@ -216,37 +210,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedDatabaseSecurityAlertPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedDatabaseSecurityAlertPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -264,6 +256,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_events_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_events_operations.py index 4f1e928b1afd9..a6c7a7bd68ccd 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_events_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_events_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_security_events_operations import build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -71,7 +77,8 @@ def list_by_database( :param skiptoken: An opaque token that identifies a starting point in the collection. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityEventCollection or the result of cls(response) + :return: An iterator like instance of either SecurityEventCollection or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SecurityEventCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -80,45 +87,43 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + skip=skip, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + skip=skip, + top=top, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SecurityEventCollection', pipeline_response) + deserialized = self._deserialize("SecurityEventCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -136,6 +141,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py index 12591efd60842..9f77a3b916338 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_sensitivity_labels_operations import build_create_or_update_request, build_delete_request, build_disable_recommendation_request, build_enable_recommendation_request, build_get_request, build_list_current_by_database_request, build_list_recommended_by_database_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -79,32 +85,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + sensitivity_label_source=sensitivity_label_source, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -118,8 +114,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -158,38 +157,26 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SensitivityLabel') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,8 +194,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -244,31 +234,21 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,6 +261,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace_async async def disable_recommendation( self, resource_group_name: str, @@ -316,31 +298,21 @@ async def disable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.disable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_disable_recommendation_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.disable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -353,6 +325,8 @@ async def disable_recommendation( disable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable'} # type: ignore + + @distributed_trace_async async def enable_recommendation( self, resource_group_name: str, @@ -389,31 +363,21 @@ async def enable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.enable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_enable_recommendation_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.enable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,6 +390,8 @@ async def enable_recommendation( enable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable'} # type: ignore + + @distributed_trace def list_current_by_database( self, resource_group_name: str, @@ -452,8 +418,10 @@ def list_current_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] @@ -461,43 +429,41 @@ def list_current_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_current_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if count is not None: - query_parameters['$count'] = self._serialize.query("count", count, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_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, + skip_token=skip_token, + count=count, + filter=filter, + template_url=self.list_current_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_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, + skip_token=skip_token, + count=count, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -515,11 +481,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_current_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -549,31 +517,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SensitivityLabelUpdateList') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -586,6 +546,8 @@ async def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + + @distributed_trace def list_recommended_by_database( self, resource_group_name: str, @@ -613,8 +575,10 @@ def list_recommended_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] @@ -622,43 +586,41 @@ def list_recommended_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_recommended_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if include_disabled_recommendations is not None: - query_parameters['includeDisabledRecommendations'] = self._serialize.query("include_disabled_recommendations", include_disabled_recommendations, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_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, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=self.list_recommended_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_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, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -676,6 +638,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_tables_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_tables_operations.py index 44b76d8ad5118..df241253d4e85 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_tables_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_tables_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_tables_operations import build_get_request, build_list_by_schema_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_schema( self, resource_group_name: str, @@ -64,7 +70,8 @@ def list_by_schema( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseTableListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseTableListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseTableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -73,40 +80,39 @@ def list_by_schema( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_schema.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_schema.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseTableListResult', pipeline_response) + deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,11 +130,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -161,30 +169,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -198,4 +196,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py index 1257164b8883b..db4104a474afb 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_transparent_data_encryption_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -71,29 +77,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,8 +103,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -142,34 +141,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedTransparentDataEncryption') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedTransparentDataEncryption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,8 +176,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -207,8 +199,10 @@ def list_by_database( encryption is defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedTransparentDataEncryptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryptionListResult] + :return: An iterator like instance of either ManagedTransparentDataEncryptionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedTransparentDataEncryptionListResult"] @@ -216,37 +210,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedTransparentDataEncryptionListResult', pipeline_response) + deserialized = self._deserialize("ManagedTransparentDataEncryptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -264,6 +256,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py index f695351598019..27c9d209722c4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_vulnerability_assessment_rule_baselines_operations import build_create_or_update_request, build_delete_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -77,31 +82,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -115,8 +110,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -157,36 +155,26 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -200,8 +188,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -239,29 +230,21 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,3 +256,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py index ce14b2f5af91e..d86377754ab3f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_database_vulnerability_assessment_scans_operations import build_export_request, build_get_request, build_initiate_scan_request_initial, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,28 +62,20 @@ async def _initiate_scan_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._initiate_scan_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_initiate_scan_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self._initiate_scan_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +88,8 @@ async def _initiate_scan_initial( _initiate_scan_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + + @distributed_trace_async async def begin_initiate_scan( self, resource_group_name: str, @@ -115,15 +114,17 @@ async def begin_initiate_scan( :type scan_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -140,24 +141,14 @@ async def begin_initiate_scan( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -169,8 +160,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_initiate_scan.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + @distributed_trace_async async def export( self, resource_group_name: str, @@ -203,30 +196,20 @@ async def export( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.export.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.export.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -244,8 +227,11 @@ async def export( return cls(pipeline_response, deserialized, {}) return deserialized + export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -266,8 +252,10 @@ def list_by_database( :param vulnerability_assessment_name: The name of the vulnerability assessment. :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] + :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecordListResult"] @@ -275,38 +263,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VulnerabilityAssessmentScanRecordListResult', pipeline_response) + deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -324,11 +311,13 @@ async def get_next(next_link=None): 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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -361,30 +350,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -398,4 +377,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py index 6e028361dbd91..b78108eaeb4f2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_database_vulnerability_assessments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -71,29 +77,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,8 +103,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -142,34 +141,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,8 +176,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -219,27 +211,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -252,6 +236,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -270,8 +256,10 @@ def list_by_database( defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] + :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseVulnerabilityAssessmentListResult"] @@ -279,37 +267,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -327,6 +313,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_databases_operations.py index 45fd04d2d6652..7843f58684762 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_databases_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_databases_operations import build_complete_restore_request_initial, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_instance_request, build_list_inaccessible_by_instance_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseListResult] + :return: An iterator like instance of either ManagedDatabaseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabaseListResult"] @@ -66,36 +74,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +118,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,28 +151,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +176,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -194,33 +193,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedDatabase') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedDatabase') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -239,8 +228,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -262,15 +254,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedDatabase :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. + :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 ManagedDatabase or the result of cls(response) + :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 ManagedDatabase or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabase"] lro_delay = kwargs.pop( 'polling_interval', @@ -283,28 +279,21 @@ async def begin_create_or_update( managed_instance_name=managed_instance_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedDatabase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -316,6 +305,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore async def _delete_initial( @@ -330,26 +320,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -362,6 +344,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -380,15 +364,17 @@ async def begin_delete( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -403,22 +389,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -430,6 +408,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore async def _update_initial( @@ -445,33 +424,23 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedDatabaseUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedDatabaseUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -487,8 +456,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -510,15 +482,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate :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. + :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 ManagedDatabase or the result of cls(response) + :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 ManagedDatabase or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabase"] lro_delay = kwargs.pop( 'polling_interval', @@ -531,28 +507,21 @@ async def begin_update( managed_instance_name=managed_instance_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedDatabase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -564,6 +533,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore async def _complete_restore_initial( @@ -579,31 +549,23 @@ async def _complete_restore_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._complete_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'CompleteDatabaseRestoreDefinition') + + request = build_complete_restore_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._complete_restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CompleteDatabaseRestoreDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -616,6 +578,8 @@ async def _complete_restore_initial( _complete_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore'} # type: ignore + + @distributed_trace_async async def begin_complete_restore( self, resource_group_name: str, @@ -637,15 +601,18 @@ async def begin_complete_restore( :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -658,25 +625,18 @@ async def begin_complete_restore( managed_instance_name=managed_instance_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -688,8 +648,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_complete_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore'} # type: ignore + @distributed_trace def list_inaccessible_by_instance( self, resource_group_name: str, @@ -704,8 +666,10 @@ def list_inaccessible_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseListResult] + :return: An iterator like instance of either ManagedDatabaseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabaseListResult"] @@ -713,36 +677,33 @@ def list_inaccessible_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_inaccessible_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_inaccessible_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -760,6 +721,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py index 5c5330673b747..af0a006f2d48a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_administrators_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministratorListResult] + :return: An iterator like instance of either ManagedInstanceAdministratorListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAdministratorListResult"] @@ -66,36 +74,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +118,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,28 +151,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +176,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -194,33 +193,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceAdministrator') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceAdministrator') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -239,8 +228,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -262,15 +254,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator :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. + :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 ManagedInstanceAdministrator or the result of cls(response) + :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 ManagedInstanceAdministrator or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAdministrator"] lro_delay = kwargs.pop( 'polling_interval', @@ -283,28 +279,21 @@ async def begin_create_or_update( managed_instance_name=managed_instance_name, administrator_name=administrator_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceAdministrator', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -316,6 +305,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore async def _delete_initial( @@ -330,26 +320,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -362,6 +344,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -380,15 +364,17 @@ async def begin_delete( :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -403,22 +389,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -430,4 +408,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py index 49ed6f9ebf45a..276abd6f6516e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_azure_ad_only_authentications_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceAzureADOnlyAuthentication') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceAzureADOnlyAuthentication') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -189,15 +180,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication :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. + :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 ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAzureADOnlyAuthentication"] lro_delay = kwargs.pop( 'polling_interval', @@ -210,28 +206,21 @@ async def begin_create_or_update( managed_instance_name=managed_instance_name, authentication_name=authentication_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceAzureADOnlyAuthentication', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -243,6 +232,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore async def _delete_initial( @@ -257,26 +247,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -289,6 +271,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -307,15 +291,17 @@ async def begin_delete( :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -330,22 +316,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -357,8 +335,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -373,8 +353,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceAzureADOnlyAuthListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthListResult] + :return: An iterator like instance of either ManagedInstanceAzureADOnlyAuthListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAzureADOnlyAuthListResult"] @@ -382,36 +364,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceAzureADOnlyAuthListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceAzureADOnlyAuthListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -429,6 +408,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_encryption_protectors_operations.py index 6ddec5b79eeaf..6871737b3abdb 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_encryption_protectors_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_encryption_protectors_operations import build_create_or_update_request_initial, build_get_request, build_list_by_instance_request, build_revalidate_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,26 +60,18 @@ async def _revalidate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._revalidate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_revalidate_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self._revalidate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -87,6 +84,8 @@ async def _revalidate_initial( _revalidate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore + + @distributed_trace_async async def begin_revalidate( self, resource_group_name: str, @@ -105,15 +104,17 @@ async def begin_revalidate( :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -128,22 +129,14 @@ async def begin_revalidate( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_revalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -171,8 +166,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceEncryptionProtectorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtectorListResult] + :return: An iterator like instance of either ManagedInstanceEncryptionProtectorListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtectorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceEncryptionProtectorListResult"] @@ -180,36 +177,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceEncryptionProtectorListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceEncryptionProtectorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -227,11 +221,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -258,28 +254,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,8 +279,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -308,33 +296,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceEncryptionProtector') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceEncryptionProtector') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -350,8 +328,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -373,15 +354,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector :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. + :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 ManagedInstanceEncryptionProtector or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedInstanceEncryptionProtector + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceEncryptionProtector"] lro_delay = kwargs.pop( 'polling_interval', @@ -394,28 +380,21 @@ async def begin_create_or_update( managed_instance_name=managed_instance_name, encryption_protector_name=encryption_protector_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceEncryptionProtector', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -427,4 +406,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py index 5758fe18ae239..d2813874c0e6f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_keys_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -60,8 +66,10 @@ def list_by_instance( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceKeyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceKeyListResult] + :return: An iterator like instance of either ManagedInstanceKeyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceKeyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceKeyListResult"] @@ -69,38 +77,35 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceKeyListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceKeyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,11 +123,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,28 +156,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -184,8 +181,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -199,33 +198,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceKey') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceKey') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -244,8 +233,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -267,15 +259,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey :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. + :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 ManagedInstanceKey or the result of cls(response) + :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 ManagedInstanceKey or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceKey"] lro_delay = kwargs.pop( 'polling_interval', @@ -288,28 +284,21 @@ async def begin_create_or_update( managed_instance_name=managed_instance_name, key_name=key_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceKey', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -321,6 +310,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore async def _delete_initial( @@ -335,26 +325,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -367,6 +349,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -385,15 +369,17 @@ async def begin_delete( :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -408,22 +394,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -435,4 +413,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py index e85b2e89c7469..28c43b757c739 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_long_term_retention_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,29 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -124,34 +122,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedInstanceLongTermRetentionPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceLongTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +155,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -193,15 +184,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy :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. + :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 ManagedInstanceLongTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ManagedInstanceLongTermRetentionPolicy or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,29 +211,21 @@ async def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceLongTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,8 +237,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -268,8 +258,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionPolicyListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionPolicyListResult"] @@ -277,37 +269,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -325,6 +315,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_operations_operations.py index 08ac71893cde0..93e497f4a1e51 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_instance_operations_operations import build_cancel_request, build_get_request, build_list_by_managed_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_managed_instance( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_managed_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceOperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceOperationListResult] + :return: An iterator like instance of either ManagedInstanceOperationListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceOperationListResult"] @@ -64,36 +72,33 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceOperationListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_managed_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,8 +174,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -205,26 +205,18 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -236,3 +228,4 @@ async def cancel( return cls(pipeline_response, None, {}) cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}/cancel'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py index 3d29df0672bfe..cd1975b693432 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_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]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstancePrivateEndpointConnection') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstancePrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -161,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -184,15 +175,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection :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. + :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 ManagedInstancePrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ManagedInstancePrivateEndpointConnection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstancePrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,28 +201,21 @@ async def begin_create_or_update( managed_instance_name=managed_instance_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstancePrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -238,6 +227,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -252,26 +242,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -284,6 +266,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -302,15 +286,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -325,22 +311,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -352,8 +330,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_managed_instance( self, resource_group_name: str, @@ -368,8 +348,10 @@ def list_by_managed_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstancePrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionListResult] + :return: An iterator like instance of either ManagedInstancePrivateEndpointConnectionListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstancePrivateEndpointConnectionListResult"] @@ -377,36 +359,33 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstancePrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstancePrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -424,6 +403,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_link_resources_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_link_resources_operations.py index 025e4ac75d9e5..bc59bd59e0162 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_link_resources_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_link_resources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_instance_private_link_resources_operations import build_get_request, build_list_by_managed_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_managed_instance( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_managed_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstancePrivateLinkListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLinkListResult] + :return: An iterator like instance of either ManagedInstancePrivateLinkListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstancePrivateLinkListResult"] @@ -64,36 +72,33 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstancePrivateLinkListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstancePrivateLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_managed_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,4 +174,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py index 41750d0fdc101..7dd6d30a041c1 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async 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_tde_certificates_operations import build_create_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,30 +58,22 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'TdeCertificate') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TdeCertificate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,6 +86,8 @@ async def _create_initial( _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -108,15 +106,18 @@ async def begin_create( :type parameters: ~azure.mgmt.sql.models.TdeCertificate :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -128,24 +129,18 @@ async def begin_create( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -157,4 +152,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py index 3adb0b8248861..c4d146344015d 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._managed_instance_vulnerability_assessments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -68,28 +74,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,8 +99,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -137,33 +136,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,8 +170,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -210,26 +202,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,6 +226,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -257,8 +243,10 @@ def list_by_instance( assessments is defined. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessmentListResult] + :return: An iterator like instance of either ManagedInstanceVulnerabilityAssessmentListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceVulnerabilityAssessmentListResult"] @@ -266,36 +254,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -313,6 +298,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instances_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instances_operations.py index 0cfbe4c6ca0e4..3944e111eaebf 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instances_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instances_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_instances_operations import build_create_or_update_request_initial, build_delete_request_initial, build_failover_request_initial, build_get_request, build_list_by_instance_pool_request, build_list_by_managed_instance_request, build_list_by_resource_group_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance_pool( self, resource_group_name: str, @@ -60,8 +66,10 @@ def list_by_instance_pool( :param expand: The child resources to include in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] + :return: An iterator like instance of either ManagedInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceListResult"] @@ -69,38 +77,35 @@ def list_by_instance_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_instance_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,11 +123,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances'} # type: ignore + @distributed_trace def list( self, expand: Optional[str] = None, @@ -133,8 +140,10 @@ def list( :param expand: The child resources to include in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] + :return: An iterator like instance of either ManagedInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceListResult"] @@ -142,36 +151,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -189,11 +193,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -208,8 +214,10 @@ def list_by_resource_group( :param expand: The child resources to include in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] + :return: An iterator like instance of either ManagedInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceListResult"] @@ -217,37 +225,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -265,11 +269,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -296,29 +302,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -332,8 +327,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -346,32 +343,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstance') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstance') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -390,8 +377,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -410,15 +400,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstance :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. + :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 ManagedInstance or the result of cls(response) + :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 ManagedInstance or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstance"] lro_delay = kwargs.pop( 'polling_interval', @@ -430,27 +424,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstance', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -462,6 +450,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore async def _delete_initial( @@ -475,25 +464,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,6 +487,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -521,15 +504,17 @@ async def begin_delete( :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -543,21 +528,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -569,6 +547,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore async def _update_initial( @@ -583,32 +562,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -624,8 +593,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -644,15 +616,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate :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. + :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 ManagedInstance or the result of cls(response) + :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 ManagedInstance or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstance"] lro_delay = kwargs.pop( 'polling_interval', @@ -664,27 +640,21 @@ async def begin_update( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstance', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -696,8 +666,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + @distributed_trace def list_by_managed_instance( self, resource_group_name: str, @@ -735,7 +707,8 @@ def list_by_managed_instance( :param observation_metric: Metric to be used for ranking top queries. Default is 'cpu'. :type observation_metric: str or ~azure.mgmt.sql.models.MetricType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopQueriesListResult or the result of cls(response) + :return: An iterator like instance of either TopQueriesListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.TopQueriesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -744,50 +717,47 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if number_of_queries is not None: - query_parameters['numberOfQueries'] = self._serialize.query("number_of_queries", number_of_queries, 'int') - if databases is not None: - query_parameters['databases'] = self._serialize.query("databases", databases, 'str') - if start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - if end_time is not None: - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'str') - if aggregation_function is not None: - query_parameters['aggregationFunction'] = self._serialize.query("aggregation_function", aggregation_function, 'str') - if observation_metric is not None: - query_parameters['observationMetric'] = self._serialize.query("observation_metric", observation_metric, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + number_of_queries=number_of_queries, + databases=databases, + start_time=start_time, + end_time=end_time, + interval=interval, + aggregation_function=aggregation_function, + observation_metric=observation_metric, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + number_of_queries=number_of_queries, + databases=databases, + start_time=start_time, + end_time=end_time, + interval=interval, + aggregation_function=aggregation_function, + observation_metric=observation_metric, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TopQueriesListResult', pipeline_response) + deserialized = self._deserialize("TopQueriesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -805,6 +775,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -822,27 +793,18 @@ async def _failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if replica_type is not None: - query_parameters['replicaType'] = self._serialize.query("replica_type", replica_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -855,6 +817,8 @@ async def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover'} # type: ignore + + @distributed_trace_async async def begin_failover( self, resource_group_name: str, @@ -873,15 +837,17 @@ async def begin_failover( :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -896,21 +862,14 @@ async def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -922,4 +881,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py index f4057a1a66729..8628a22015308 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_restorable_dropped_database_backup_short_term_retention_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_restorable_dropped_database_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,29 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -124,34 +122,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +155,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -193,15 +184,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ManagedBackupShortTermRetentionPolicy or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,29 +211,21 @@ async def begin_create_or_update( restorable_dropped_database_id=restorable_dropped_database_id, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,6 +237,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore async def _update_initial( @@ -265,34 +254,24 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,8 +287,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -334,15 +316,20 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 + ManagedBackupShortTermRetentionPolicy or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -356,29 +343,21 @@ async def begin_update( restorable_dropped_database_id=restorable_dropped_database_id, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -390,8 +369,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_restorable_dropped_database( self, resource_group_name: str, @@ -409,8 +390,10 @@ def list_by_restorable_dropped_database( :param restorable_dropped_database_id: :type restorable_dropped_database_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] + :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicyListResult"] @@ -418,37 +401,35 @@ def list_by_restorable_dropped_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_restorable_dropped_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_restorable_dropped_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=self.list_by_restorable_dropped_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_restorable_dropped_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -466,6 +447,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py index 3bfa09c9a56bd..6e8109e2f26d8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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_server_security_alert_policies_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]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedServerSecurityAlertPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedServerSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -161,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -184,15 +175,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy :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. + :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 ManagedServerSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedServerSecurityAlertPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedServerSecurityAlertPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,28 +201,21 @@ async def begin_create_or_update( managed_instance_name=managed_instance_name, security_alert_policy_name=security_alert_policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedServerSecurityAlertPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -238,8 +227,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -254,8 +245,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedServerSecurityAlertPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicyListResult] + :return: An iterator like instance of either ManagedServerSecurityAlertPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedServerSecurityAlertPolicyListResult"] @@ -263,36 +256,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedServerSecurityAlertPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedServerSecurityAlertPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -310,6 +300,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_operations.py index 416ddc214ff53..0adee9e33042e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -57,30 +63,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +101,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_operations_health_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_operations_health_operations.py deleted file mode 100644 index a2a49a90861fc..0000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_operations_health_operations.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class OperationsHealthOperations: - """OperationsHealthOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.sql.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_location( - self, - location_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.OperationsHealthListResult"]: - """Gets a service operation health status. - - :param location_name: The name of the region where the resource is located. - :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsHealthListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OperationsHealthListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsHealthListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsHealthListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/operationsHealth'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py index 4ba356d375971..1b63320d029f3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._outbound_firewall_rules_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'OutboundFirewallRule') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OutboundFirewallRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -187,15 +178,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule :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. + :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 OutboundFirewallRule or the result of cls(response) + :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 OutboundFirewallRule or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundFirewallRule"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,28 +203,21 @@ async def begin_create_or_update( server_name=server_name, outbound_rule_fqdn=outbound_rule_fqdn, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OutboundFirewallRule', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -241,6 +229,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore async def _delete_initial( @@ -255,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -305,15 +288,17 @@ async def begin_delete( :type outbound_rule_fqdn: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,22 +313,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -355,8 +332,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -371,8 +350,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OutboundFirewallRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundFirewallRuleListResult] + :return: An iterator like instance of either OutboundFirewallRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundFirewallRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundFirewallRuleListResult"] @@ -380,36 +361,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OutboundFirewallRuleListResult', pipeline_response) + deserialized = self._deserialize("OutboundFirewallRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,6 +405,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_endpoint_connections_operations.py index e7954d801e54b..a1e3afdaf5eb9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_endpoint_connections_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -161,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -184,15 +175,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection :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. + :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 PrivateEndpointConnection or the result of cls(response) + :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 PrivateEndpointConnection or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,28 +200,21 @@ async def begin_create_or_update( server_name=server_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -238,6 +226,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -252,26 +241,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -284,6 +265,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -302,15 +285,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -325,22 +310,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -352,8 +329,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -368,8 +347,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -377,36 +358,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -424,6 +402,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_link_resources_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_link_resources_operations.py index 6e48bccfcb16e..71e3014c3458c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_link_resources_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_link_resources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateLinkResourceListResult] + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] @@ -64,36 +72,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,4 +174,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py index fbfafca389b41..d45c492421eb2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._recommended_sensitivity_labels_operations import build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update( self, resource_group_name: str, @@ -69,31 +74,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,3 +102,4 @@ async def update( return cls(pipeline_response, None, {}) update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py index 315c4052dcb48..3bd19ff284b1a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._recoverable_databases_operations import build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,28 +73,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}'} # type: ignore + + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -118,8 +117,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RecoverableDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableDatabaseListResult] + :return: An iterator like instance of either RecoverableDatabaseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoverableDatabaseListResult"] @@ -127,36 +128,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RecoverableDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RecoverableDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,6 +172,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_managed_databases_operations.py index b45b9bc892a7b..4b5631b5e0f6e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_managed_databases_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._recoverable_managed_databases_operations import build_get_request, build_list_by_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RecoverableManagedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabaseListResult] + :return: An iterator like instance of either RecoverableManagedDatabaseListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoverableManagedDatabaseListResult"] @@ -64,36 +72,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RecoverableManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RecoverableManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'recoverableDatabaseName': self._serialize.url("recoverable_database_name", recoverable_database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + recoverable_database_name=recoverable_database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,4 +174,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py index 01991aa927bee..72577781c9e03 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._replication_links_operations import build_delete_request, build_failover_allow_data_loss_request_initial, build_failover_request_initial, build_get_request, build_list_by_database_request, build_list_by_server_request, build_unlink_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -72,27 +78,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,6 +103,7 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}'} # type: ignore + async def _failover_initial( self, resource_group_name: str, @@ -118,27 +117,19 @@ async def _failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -151,6 +142,8 @@ async def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover'} # type: ignore + + @distributed_trace_async async def begin_failover( self, resource_group_name: str, @@ -173,15 +166,17 @@ async def begin_failover( :type link_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -197,23 +192,14 @@ async def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -225,6 +211,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover'} # type: ignore async def _failover_allow_data_loss_initial( @@ -240,27 +227,19 @@ async def _failover_allow_data_loss_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self._failover_allow_data_loss_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_allow_data_loss_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + template_url=self._failover_allow_data_loss_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,6 +252,8 @@ async def _failover_allow_data_loss_initial( _failover_allow_data_loss_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss'} # type: ignore + + @distributed_trace_async async def begin_failover_allow_data_loss( self, resource_group_name: str, @@ -295,15 +276,17 @@ async def begin_failover_allow_data_loss( :type link_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -319,23 +302,14 @@ async def begin_failover_allow_data_loss( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -347,6 +321,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover_allow_data_loss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss'} # type: ignore async def _unlink_initial( @@ -363,32 +338,24 @@ async def _unlink_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._unlink_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'UnlinkParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_unlink_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + content_type=content_type, + json=_json, + template_url=self._unlink_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UnlinkParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -401,6 +368,8 @@ async def _unlink_initial( _unlink_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink'} # type: ignore + + @distributed_trace_async async def begin_unlink( self, resource_group_name: str, @@ -425,15 +394,18 @@ async def begin_unlink( :type parameters: ~azure.mgmt.sql.models.UnlinkParameters :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -447,26 +419,18 @@ async def begin_unlink( database_name=database_name, link_id=link_id, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -478,8 +442,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_unlink.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -497,8 +463,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationLinkListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLinkListResult] + :return: An iterator like instance of either ReplicationLinkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationLinkListResult"] @@ -506,37 +474,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReplicationLinkListResult', pipeline_response) + deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -554,11 +520,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -588,29 +556,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -624,8 +582,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}'} # type: ignore + + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -640,8 +601,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationLinkListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLinkListResult] + :return: An iterator like instance of either ReplicationLinkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationLinkListResult"] @@ -649,36 +612,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReplicationLinkListResult', pipeline_response) + deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -696,6 +656,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py index 9eb106ad30e67..1202b0fafd751 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_dropped_databases_operations import build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDroppedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabaseListResult] + :return: An iterator like instance of either RestorableDroppedDatabaseListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedDatabaseListResult"] @@ -64,36 +72,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDroppedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RestorableDroppedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,4 +174,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py index cdaf2db7aea37..b5a2f124dd8a0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_dropped_managed_databases_operations import build_get_request, build_list_by_instance_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDroppedManagedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabaseListResult] + :return: An iterator like instance of either RestorableDroppedManagedDatabaseListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedManagedDatabaseListResult"] @@ -64,36 +72,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDroppedManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RestorableDroppedManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,4 +174,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py index 8d518c4050816..32e39018867ed 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._restore_points_operations import build_create_request_initial, build_delete_request, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -60,7 +66,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorePointListResult or the result of cls(response) + :return: An iterator like instance of either RestorePointListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorePointListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,37 +76,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorePointListResult', pipeline_response) + deserialized = self._deserialize("RestorePointListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,6 +122,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -135,33 +141,23 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'CreateDatabaseRestorePointDefinition') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CreateDatabaseRestorePointDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -180,8 +176,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -203,15 +202,19 @@ async def begin_create( :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition :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. + :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 RestorePoint or the result of cls(response) + :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 RestorePoint or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -224,28 +227,21 @@ async def begin_create( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('RestorePoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -257,8 +253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -288,29 +286,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'restorePointName': self._serialize.url("restore_point_name", restore_point_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -324,8 +312,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -355,27 +346,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'restorePointName': self._serialize.url("restore_point_name", restore_point_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -387,3 +370,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py index b1df2c679913f..2eecce87c886a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._sensitivity_labels_operations import build_create_or_update_request, build_delete_request, build_disable_recommendation_request, build_enable_recommendation_request, build_get_request, build_list_current_by_database_request, build_list_recommended_by_database_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_current_by_database( self, resource_group_name: str, @@ -67,8 +73,10 @@ def list_current_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] @@ -76,43 +84,41 @@ def list_current_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_current_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if count is not None: - query_parameters['$count'] = self._serialize.query("count", count, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + count=count, + filter=filter, + template_url=self.list_current_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + count=count, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,11 +136,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_current_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -164,31 +172,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SensitivityLabelUpdateList') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,6 +201,8 @@ async def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + + @distributed_trace def list_recommended_by_database( self, resource_group_name: str, @@ -228,8 +230,10 @@ def list_recommended_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] @@ -237,43 +241,41 @@ def list_recommended_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_recommended_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if include_disabled_recommendations is not None: - query_parameters['includeDisabledRecommendations'] = self._serialize.query("include_disabled_recommendations", include_disabled_recommendations, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=self.list_recommended_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -291,11 +293,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_recommended_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels'} # type: ignore + @distributed_trace_async async def enable_recommendation( self, resource_group_name: str, @@ -332,31 +336,21 @@ async def enable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.enable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_enable_recommendation_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.enable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -369,6 +363,8 @@ async def enable_recommendation( enable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable'} # type: ignore + + @distributed_trace_async async def disable_recommendation( self, resource_group_name: str, @@ -404,31 +400,21 @@ async def disable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.disable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_disable_recommendation_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.disable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -441,6 +427,8 @@ async def disable_recommendation( disable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -479,32 +467,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + sensitivity_label_source=sensitivity_label_source, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -518,8 +496,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -558,38 +539,26 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SensitivityLabel') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -607,8 +576,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -644,31 +616,21 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -680,3 +642,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py index 223efd1a1d65c..1216b1ad10951 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._server_advisors_operations import build_get_request, build_list_by_server_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_server( self, resource_group_name: str, @@ -66,29 +71,18 @@ async def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +96,11 @@ async def list_by_server( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -130,28 +127,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -196,33 +186,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Advisor') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Advisor') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -236,4 +216,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py index d37c7571b40b6..4dd6bb96aeb53 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._server_automatic_tuning_operations import build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -63,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,8 +92,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -125,32 +123,22 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerAutomaticTuning') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerAutomaticTuning') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,4 +152,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py index 61d765c43e62f..73b676c9695cb 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_azure_ad_administrators_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerAzureADAdministrator') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerAzureADAdministrator') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -187,15 +178,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator :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. + :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 ServerAzureADAdministrator or the result of cls(response) + :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 ServerAzureADAdministrator or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerAzureADAdministrator"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,28 +203,21 @@ async def begin_create_or_update( server_name=server_name, administrator_name=administrator_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerAzureADAdministrator', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -241,6 +229,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore async def _delete_initial( @@ -255,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -305,15 +288,17 @@ async def begin_delete( :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,22 +313,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -355,8 +332,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -371,7 +350,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AdministratorListResult or the result of cls(response) + :return: An iterator like instance of either AdministratorListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.AdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -380,36 +360,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AdministratorListResult', pipeline_response) + deserialized = self._deserialize("AdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,6 +404,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_only_authentications_operations.py index bd71ff83c2037..93fed4ee31c82 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_only_authentications_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_only_authentications_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_azure_ad_only_authentications_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerAzureADOnlyAuthentication') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerAzureADOnlyAuthentication') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -189,15 +180,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication :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. + :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 ServerAzureADOnlyAuthentication or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ServerAzureADOnlyAuthentication or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerAzureADOnlyAuthentication"] lro_delay = kwargs.pop( 'polling_interval', @@ -210,28 +206,21 @@ async def begin_create_or_update( server_name=server_name, authentication_name=authentication_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerAzureADOnlyAuthentication', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -243,6 +232,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore async def _delete_initial( @@ -257,26 +247,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -289,6 +271,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -307,15 +291,17 @@ async def begin_delete( :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -330,22 +316,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -357,8 +335,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -373,8 +353,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureADOnlyAuthListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.AzureADOnlyAuthListResult] + :return: An iterator like instance of either AzureADOnlyAuthListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.AzureADOnlyAuthListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureADOnlyAuthListResult"] @@ -382,36 +364,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AzureADOnlyAuthListResult', pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -429,6 +408,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_blob_auditing_policies_operations.py index 2439a5f1009e0..3604b17eaa26c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_blob_auditing_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_blob_auditing_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,29 +72,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +96,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -116,34 +112,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerBlobAuditingPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,8 +143,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -179,15 +166,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy :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. + :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 ServerBlobAuditingPolicy or the result of cls(response) + :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 ServerBlobAuditingPolicy or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -199,29 +190,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerBlobAuditingPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - blob_auditing_policy_name = "default" - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -233,8 +216,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -249,8 +234,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerBlobAuditingPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerBlobAuditingPolicyListResult] + :return: An iterator like instance of either ServerBlobAuditingPolicyListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicyListResult"] @@ -258,36 +245,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -305,6 +289,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py index d279ea17ebe7b..885f64ecb183e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_communication_links_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -69,26 +75,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + communication_link_name=communication_link_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,6 +99,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -127,28 +127,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + communication_link_name=communication_link_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +152,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -177,33 +169,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerCommunicationLink') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + communication_link_name=communication_link_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerCommunicationLink') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -219,8 +201,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -242,15 +227,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink :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. + :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 ServerCommunicationLink or the result of cls(response) + :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 ServerCommunicationLink or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerCommunicationLink"] lro_delay = kwargs.pop( 'polling_interval', @@ -263,28 +252,21 @@ async def begin_create_or_update( server_name=server_name, communication_link_name=communication_link_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerCommunicationLink', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -296,8 +278,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -312,8 +296,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerCommunicationLinkListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerCommunicationLinkListResult] + :return: An iterator like instance of either ServerCommunicationLinkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerCommunicationLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerCommunicationLinkListResult"] @@ -321,36 +307,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerCommunicationLinkListResult', pipeline_response) + deserialized = self._deserialize("ServerCommunicationLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -368,6 +351,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py index 96c09f77bba5b..fa70db4acc67a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_connection_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerConnectionPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerConnectionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -161,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -184,15 +175,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ServerConnectionPolicy or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServerConnectionPolicy or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,28 +200,21 @@ async def begin_create_or_update( server_name=server_name, connection_policy_name=connection_policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -238,8 +226,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -254,8 +244,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerConnectionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicyListResult] + :return: An iterator like instance of either ServerConnectionPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicyListResult"] @@ -263,36 +255,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerConnectionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ServerConnectionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -310,6 +299,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dev_ops_audit_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dev_ops_audit_settings_operations.py index 211a88fbbb30b..d60c83a25bc3a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dev_ops_audit_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dev_ops_audit_settings_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_dev_ops_audit_settings_operations import build_create_or_update_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -70,28 +76,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'devOpsAuditingSettingsName': self._serialize.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +101,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -120,33 +118,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'devOpsAuditingSettingsName': self._serialize.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerDevOpsAuditingSettings') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerDevOpsAuditingSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -186,15 +177,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings :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. + :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 ServerDevOpsAuditingSettings or the result of cls(response) + :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 ServerDevOpsAuditingSettings or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDevOpsAuditingSettings"] lro_delay = kwargs.pop( 'polling_interval', @@ -207,28 +202,21 @@ async def begin_create_or_update( server_name=server_name, dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerDevOpsAuditingSettings', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'devOpsAuditingSettingsName': self._serialize.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -240,8 +228,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -256,8 +246,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerDevOpsAuditSettingsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditSettingsListResult] + :return: An iterator like instance of either ServerDevOpsAuditSettingsListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditSettingsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDevOpsAuditSettingsListResult"] @@ -265,36 +257,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerDevOpsAuditSettingsListResult', pipeline_response) + deserialized = self._deserialize("ServerDevOpsAuditSettingsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -312,6 +301,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dns_aliases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dns_aliases_operations.py index 516029d276d79..44d7285bbdc38 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dns_aliases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dns_aliases_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_dns_aliases_operations import build_acquire_request_initial, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -118,28 +116,18 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,8 +146,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -178,15 +169,18 @@ async def begin_create_or_update( :type dns_alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 ServerDnsAlias or the result of cls(response) + :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 ServerDnsAlias or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDnsAlias"] lro_delay = kwargs.pop( 'polling_interval', @@ -201,25 +195,17 @@ async def begin_create_or_update( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerDnsAlias', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -231,6 +217,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore async def _delete_initial( @@ -245,26 +232,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +256,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -295,15 +276,17 @@ async def begin_delete( :type dns_alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -318,22 +301,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -345,8 +320,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -361,8 +338,10 @@ def list_by_server( :param server_name: The name of the server that the alias is pointing to. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerDnsAliasListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDnsAliasListResult] + :return: An iterator like instance of either ServerDnsAliasListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDnsAliasListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDnsAliasListResult"] @@ -370,36 +349,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerDnsAliasListResult', pipeline_response) + deserialized = self._deserialize("ServerDnsAliasListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -417,6 +393,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -435,33 +412,23 @@ async def _acquire_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._acquire_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerDnsAliasAcquisition') + + request = build_acquire_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._acquire_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerDnsAliasAcquisition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -477,8 +444,11 @@ async def _acquire_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _acquire_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire'} # type: ignore + + @distributed_trace_async async def begin_acquire( self, resource_group_name: str, @@ -500,15 +470,19 @@ async def begin_acquire( :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition :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. + :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 ServerDnsAlias or the result of cls(response) + :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 ServerDnsAlias or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDnsAlias"] lro_delay = kwargs.pop( 'polling_interval', @@ -521,28 +495,21 @@ async def begin_acquire( server_name=server_name, dns_alias_name=dns_alias_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerDnsAlias', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -554,4 +521,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_acquire.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py index eb63e6ce66965..c082f3b3c4595 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_keys_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -66,36 +72,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerKeyListResult', pipeline_response) + deserialized = self._deserialize("ServerKeyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +174,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -194,33 +191,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerKey') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerKey') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -239,8 +226,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -265,15 +255,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerKey :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. + :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 ServerKey or the result of cls(response) + :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 ServerKey or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerKey"] lro_delay = kwargs.pop( 'polling_interval', @@ -286,28 +280,21 @@ async def begin_create_or_update( server_name=server_name, key_name=key_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerKey', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -319,6 +306,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore async def _delete_initial( @@ -333,26 +321,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -365,6 +345,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -383,15 +365,17 @@ async def begin_delete( :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -406,22 +390,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -433,4 +409,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py index 0c6f8a9622172..2d4a64bc84ea8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._server_operations_operations import build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerOperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerOperationListResult] + :return: An iterator like instance of either ServerOperationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerOperationListResult"] @@ -64,36 +72,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerOperationListResult', pipeline_response) + deserialized = self._deserialize("ServerOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,6 +116,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py index 8086f41e9c49b..81a2b2d05c56f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_security_alert_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerSecurityAlertPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -161,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -184,15 +175,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy :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. + :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 ServerSecurityAlertPolicy or the result of cls(response) + :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 ServerSecurityAlertPolicy or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,28 +200,21 @@ async def begin_create_or_update( server_name=server_name, security_alert_policy_name=security_alert_policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerSecurityAlertPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -238,8 +226,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -254,8 +244,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogicalServerSecurityAlertPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LogicalServerSecurityAlertPolicyListResult] + :return: An iterator like instance of either LogicalServerSecurityAlertPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LogicalServerSecurityAlertPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalServerSecurityAlertPolicyListResult"] @@ -263,36 +255,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LogicalServerSecurityAlertPolicyListResult', pipeline_response) + deserialized = self._deserialize("LogicalServerSecurityAlertPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -310,6 +299,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_groups_operations.py index 9779fd3e50df8..0b738ba0a82f2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._server_trust_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_instance_request, build_list_by_location_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerTrustGroup') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerTrustGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -187,15 +178,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup :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. + :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 ServerTrustGroup or the result of cls(response) + :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 ServerTrustGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerTrustGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,28 +203,21 @@ async def begin_create_or_update( location_name=location_name, server_trust_group_name=server_trust_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerTrustGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -241,6 +229,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore async def _delete_initial( @@ -255,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -305,15 +288,17 @@ async def begin_delete( :type server_trust_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,22 +313,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -355,8 +332,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + @distributed_trace def list_by_location( self, resource_group_name: str, @@ -371,8 +350,10 @@ def list_by_location( :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerTrustGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroupListResult] + :return: An iterator like instance of either ServerTrustGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerTrustGroupListResult"] @@ -380,36 +361,33 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerTrustGroupListResult', pipeline_response) + deserialized = self._deserialize("ServerTrustGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,11 +405,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups'} # type: ignore + @distributed_trace def list_by_instance( self, resource_group_name: str, @@ -446,8 +426,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerTrustGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroupListResult] + :return: An iterator like instance of either ServerTrustGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerTrustGroupListResult"] @@ -455,36 +437,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerTrustGroupListResult', pipeline_response) + deserialized = self._deserialize("ServerTrustGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -502,6 +481,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_usages_operations.py index 190d6fd086a88..e481e4db8b297 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_usages_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._server_usages_operations import build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -55,7 +61,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerUsageListResult or the result of cls(response) + :return: An iterator like instance of either ServerUsageListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerUsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -64,36 +71,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerUsageListResult', pipeline_response) + deserialized = self._deserialize("ServerUsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,6 +115,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_vulnerability_assessments_operations.py index 8193fde745f2f..7ccc89dadfefa 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_vulnerability_assessments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._server_vulnerability_assessments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,28 +73,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -135,33 +134,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +168,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -207,26 +199,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -239,6 +223,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -253,8 +239,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessmentListResult] + :return: An iterator like instance of either ServerVulnerabilityAssessmentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessmentListResult"] @@ -262,36 +250,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -309,6 +294,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_servers_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_servers_operations.py index 112e6c5d3d49a..4c90702dff727 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_servers_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_servers_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._servers_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_import_database_request_initial, build_list_by_resource_group_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -66,37 +72,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerListResult', pipeline_response) + deserialized = self._deserialize("ServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,11 +116,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -145,29 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,8 +174,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -195,32 +190,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Server') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Server') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -239,8 +224,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -259,15 +247,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.Server :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. + :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 Server or the result of cls(response) + :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 Server or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Server"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,27 +271,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Server', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -311,6 +297,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore async def _delete_initial( @@ -324,25 +311,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -355,6 +334,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -370,15 +351,17 @@ async def begin_delete( :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -392,21 +375,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -418,6 +394,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore async def _update_initial( @@ -432,32 +409,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -473,8 +440,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -493,15 +463,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.ServerUpdate :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. + :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 Server or the result of cls(response) + :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 Server or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Server"] lro_delay = kwargs.pop( 'polling_interval', @@ -513,27 +487,21 @@ async def begin_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Server', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -545,8 +513,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + @distributed_trace def list( self, expand: Optional[str] = None, @@ -566,36 +536,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServerListResult', pipeline_response) + deserialized = self._deserialize("ServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -613,6 +578,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -630,32 +596,22 @@ async def _import_database_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._import_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ImportNewDatabaseDefinition') + + request = build_import_database_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._import_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ImportNewDatabaseDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -671,8 +627,11 @@ async def _import_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _import_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import'} # type: ignore + + @distributed_trace_async async def begin_import_database( self, resource_group_name: str, @@ -691,15 +650,19 @@ async def begin_import_database( :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition :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. + :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 ImportExportOperationResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -711,27 +674,21 @@ async def begin_import_database( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -743,8 +700,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_import_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import'} # type: ignore + @distributed_trace_async async def check_name_availability( self, parameters: "_models.CheckNameAvailabilityRequest", @@ -764,30 +723,20 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailabilityRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -801,4 +750,6 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py index 3f01db240a829..5eaf0f4266e40 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._service_objectives_operations import build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,28 +73,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'serviceObjectiveName': self._serialize.url("service_objective_name", service_objective_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + service_objective_name=service_objective_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}'} # type: ignore + + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -118,8 +117,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceObjectiveListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServiceObjectiveListResult] + :return: An iterator like instance of either ServiceObjectiveListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServiceObjectiveListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceObjectiveListResult"] @@ -127,36 +128,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServiceObjectiveListResult', pipeline_response) + deserialized = self._deserialize("ServiceObjectiveListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,6 +172,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_agent_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_agent_operations.py index 6cfc26c4fea62..9f476ed62b74f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_agent_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_agent_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._sql_agent_operations import build_create_or_update_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -63,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,8 +92,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -125,32 +123,22 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlAgentConfiguration') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SqlAgentConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,4 +152,6 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py index 821c491c216d8..0d43306f8c56b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_usages_operations import build_get_request, build_list_by_location_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_location( self, location_name: str, @@ -51,8 +57,10 @@ def list_by_location( :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionUsageListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SubscriptionUsageListResult] + :return: An iterator like instance of either SubscriptionUsageListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SubscriptionUsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionUsageListResult"] @@ -60,35 +68,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionUsageListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionUsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,11 +110,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages'} # type: ignore + @distributed_trace_async async def get( self, location_name: str, @@ -133,27 +139,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'usageName': self._serialize.url("usage_name", usage_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + usage_name=usage_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,4 +163,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_agents_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_agents_operations.py index 095cc29bc8e0c..2216061cdf906 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_agents_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_agents_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._sync_agents_operations import build_create_or_update_request_initial, build_delete_request_initial, build_generate_key_request, build_get_request, build_list_by_server_request, build_list_linked_databases_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SyncAgent') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncAgent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -187,15 +178,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.SyncAgent :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. + :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 SyncAgent or the result of cls(response) + :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 SyncAgent or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,28 +203,21 @@ async def begin_create_or_update( server_name=server_name, sync_agent_name=sync_agent_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -241,6 +229,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore async def _delete_initial( @@ -255,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -305,15 +288,17 @@ async def begin_delete( :type sync_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,22 +313,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -355,8 +332,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -380,36 +359,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncAgentListResult', pipeline_response) + deserialized = self._deserialize("SyncAgentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,11 +403,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents'} # type: ignore + @distributed_trace_async async def generate_key( self, resource_group_name: str, @@ -458,28 +436,18 @@ async def generate_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_key_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.generate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -493,8 +461,11 @@ async def generate_key( return cls(pipeline_response, deserialized, {}) return deserialized + generate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/generateKey'} # type: ignore + + @distributed_trace def list_linked_databases( self, resource_group_name: str, @@ -512,8 +483,10 @@ def list_linked_databases( :param sync_agent_name: The name of the sync agent. :type sync_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncAgentLinkedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgentLinkedDatabaseListResult] + :return: An iterator like instance of either SyncAgentLinkedDatabaseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgentLinkedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncAgentLinkedDatabaseListResult"] @@ -521,37 +494,35 @@ def list_linked_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_linked_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_linked_databases_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_linked_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_linked_databases_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncAgentLinkedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("SyncAgentLinkedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -569,6 +540,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py index 3ba9b7d383d6a..0aef427239268 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._sync_groups_operations import build_cancel_sync_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_database_request, build_list_hub_schemas_request, build_list_logs_request, build_list_sync_database_ids_request, build_refresh_hub_schema_request_initial, build_trigger_sync_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_sync_database_ids( self, location_name: str, @@ -53,8 +59,10 @@ def list_sync_database_ids( :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncDatabaseIdListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncDatabaseIdListResult] + :return: An iterator like instance of either SyncDatabaseIdListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncDatabaseIdListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncDatabaseIdListResult"] @@ -62,35 +70,31 @@ def list_sync_database_ids( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sync_database_ids.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sync_database_ids_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_sync_database_ids.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sync_database_ids_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncDatabaseIdListResult', pipeline_response) + deserialized = self._deserialize("SyncDatabaseIdListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,6 +112,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -126,27 +131,19 @@ async def _refresh_hub_schema_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._refresh_hub_schema_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_refresh_hub_schema_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self._refresh_hub_schema_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,6 +156,8 @@ async def _refresh_hub_schema_initial( _refresh_hub_schema_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema'} # type: ignore + + @distributed_trace_async async def begin_refresh_hub_schema( self, resource_group_name: str, @@ -180,15 +179,17 @@ async def begin_refresh_hub_schema( :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -204,23 +205,14 @@ async def begin_refresh_hub_schema( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -232,8 +224,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_refresh_hub_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema'} # type: ignore + @distributed_trace def list_hub_schemas( self, resource_group_name: str, @@ -254,8 +248,10 @@ def list_hub_schemas( :param sync_group_name: The name of the sync group. :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaPropertiesListResult] + :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaPropertiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncFullSchemaPropertiesListResult"] @@ -263,38 +259,37 @@ def list_hub_schemas( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_hub_schemas.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_hub_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_hub_schemas.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_hub_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncFullSchemaPropertiesListResult', pipeline_response) + deserialized = self._deserialize("SyncFullSchemaPropertiesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -312,11 +307,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_hub_schemas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas'} # type: ignore + @distributed_trace def list_logs( self, resource_group_name: str, @@ -325,7 +322,7 @@ def list_logs( sync_group_name: str, start_time: str, end_time: str, - type: Union[str, "_models.Enum60"], + type: Union[str, "_models.SyncGroupsType"], continuation_token_parameter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.SyncGroupLogListResult"]: @@ -345,11 +342,12 @@ def list_logs( :param end_time: Get logs generated before this time. :type end_time: str :param type: The types of logs to retrieve. - :type type: str or ~azure.mgmt.sql.models.Enum60 + :type type: str or ~azure.mgmt.sql.models.SyncGroupsType :param continuation_token_parameter: The continuation token for this operation. :type continuation_token_parameter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncGroupLogListResult or the result of cls(response) + :return: An iterator like instance of either SyncGroupLogListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroupLogListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -358,43 +356,45 @@ def list_logs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_logs.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - query_parameters['type'] = self._serialize.query("type", type, 'str') - if continuation_token_parameter is not None: - query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_logs_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + type=type, + continuation_token_parameter=continuation_token_parameter, + template_url=self.list_logs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_logs_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + type=type, + continuation_token_parameter=continuation_token_parameter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncGroupLogListResult', pipeline_response) + deserialized = self._deserialize("SyncGroupLogListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -412,11 +412,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs'} # type: ignore + @distributed_trace_async async def cancel_sync( self, resource_group_name: str, @@ -446,27 +448,19 @@ async def cancel_sync( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel_sync.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_sync_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_sync.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -479,6 +473,8 @@ async def cancel_sync( cancel_sync.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync'} # type: ignore + + @distributed_trace_async async def trigger_sync( self, resource_group_name: str, @@ -508,27 +504,19 @@ async def trigger_sync( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.trigger_sync.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_trigger_sync_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.trigger_sync.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -541,6 +529,8 @@ async def trigger_sync( trigger_sync.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -570,29 +560,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -606,8 +586,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -622,34 +604,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SyncGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -668,8 +640,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -694,15 +669,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.SyncGroup :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. + :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 SyncGroup or the result of cls(response) + :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 SyncGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -716,29 +695,21 @@ async def begin_create_or_update( database_name=database_name, sync_group_name=sync_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -750,6 +721,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore async def _delete_initial( @@ -765,27 +737,19 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -798,6 +762,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -819,15 +785,17 @@ async def begin_delete( :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -843,23 +811,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -871,6 +830,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore async def _update_initial( @@ -887,34 +847,24 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SyncGroup') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncGroup') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -930,8 +880,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -956,15 +909,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.SyncGroup :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. + :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 SyncGroup or the result of cls(response) + :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 SyncGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -978,29 +935,21 @@ async def begin_update( database_name=database_name, sync_group_name=sync_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1012,8 +961,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -1040,37 +991,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncGroupListResult', pipeline_response) + deserialized = self._deserialize("SyncGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1088,6 +1037,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py index 2475fc85cbd92..4d7de92c66151 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._sync_members_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_sync_group_request, build_list_member_schemas_request, build_refresh_member_schema_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -75,30 +81,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,8 +108,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -129,35 +127,25 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SyncMember') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncMember') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,8 +164,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -205,15 +196,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.SyncMember :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. + :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 SyncMember or the result of cls(response) + :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 SyncMember or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncMember"] lro_delay = kwargs.pop( 'polling_interval', @@ -228,30 +223,21 @@ async def begin_create_or_update( sync_group_name=sync_group_name, sync_member_name=sync_member_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncMember', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -263,6 +249,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore async def _delete_initial( @@ -279,28 +266,20 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -313,6 +292,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -337,15 +318,17 @@ async def begin_delete( :type sync_member_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -362,24 +345,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -391,6 +364,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore async def _update_initial( @@ -408,35 +382,25 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SyncMember') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncMember') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -452,8 +416,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -481,15 +448,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.SyncMember :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. + :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 SyncMember or the result of cls(response) + :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 SyncMember or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncMember"] lro_delay = kwargs.pop( 'polling_interval', @@ -504,30 +475,21 @@ async def begin_update( sync_group_name=sync_group_name, sync_member_name=sync_member_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncMember', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -539,8 +501,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + @distributed_trace def list_by_sync_group( self, resource_group_name: str, @@ -561,7 +525,8 @@ def list_by_sync_group( :param sync_group_name: The name of the sync group. :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncMemberListResult or the result of cls(response) + :return: An iterator like instance of either SyncMemberListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncMemberListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -570,38 +535,37 @@ def list_by_sync_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sync_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_sync_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncMemberListResult', pipeline_response) + deserialized = self._deserialize("SyncMemberListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -619,11 +583,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_sync_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers'} # type: ignore + @distributed_trace def list_member_schemas( self, resource_group_name: str, @@ -647,8 +613,10 @@ def list_member_schemas( :param sync_member_name: The name of the sync member. :type sync_member_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaPropertiesListResult] + :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaPropertiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncFullSchemaPropertiesListResult"] @@ -656,39 +624,39 @@ def list_member_schemas( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_member_schemas.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_member_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self.list_member_schemas.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_member_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SyncFullSchemaPropertiesListResult', pipeline_response) + deserialized = self._deserialize("SyncFullSchemaPropertiesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -706,6 +674,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -725,28 +694,20 @@ async def _refresh_member_schema_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._refresh_member_schema_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_refresh_member_schema_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self._refresh_member_schema_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -759,6 +720,8 @@ async def _refresh_member_schema_initial( _refresh_member_schema_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema'} # type: ignore + + @distributed_trace_async async def begin_refresh_member_schema( self, resource_group_name: str, @@ -783,15 +746,17 @@ async def begin_refresh_member_schema( :type sync_member_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -808,24 +773,14 @@ async def begin_refresh_member_schema( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -837,4 +792,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_refresh_member_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py index a79e588ff2145..4a73faebeb9e4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async 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._tde_certificates_operations import build_create_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,30 +58,22 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'TdeCertificate') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TdeCertificate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,6 +86,8 @@ async def _create_initial( _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -108,15 +106,18 @@ async def begin_create( :type parameters: ~azure.mgmt.sql.models.TdeCertificate :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -128,24 +129,18 @@ async def begin_create( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -157,4 +152,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py index cb10a75022ce1..71ee727a144eb 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._time_zones_operations import build_get_request, build_list_by_location_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_location( self, location_name: str, @@ -60,35 +66,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TimeZoneListResult', pipeline_response) + deserialized = self._deserialize("TimeZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,11 +108,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones'} # type: ignore + @distributed_trace_async async def get( self, location_name: str, @@ -133,27 +137,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'timeZoneId': self._serialize.url("time_zone_id", time_zone_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + time_zone_id=time_zone_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,4 +161,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones/{timeZoneId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py index 9da319aff594b..a5b1ee2203b24 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._transparent_data_encryptions_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -71,29 +77,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,8 +103,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -142,34 +141,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'LogicalDatabaseTransparentDataEncryption') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogicalDatabaseTransparentDataEncryption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -188,8 +177,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -208,8 +200,10 @@ def list_by_database( encryption is defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryptionListResult] + :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryptionListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalDatabaseTransparentDataEncryptionListResult"] @@ -217,37 +211,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryptionListResult', pipeline_response) + deserialized = self._deserialize("LogicalDatabaseTransparentDataEncryptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -265,6 +257,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_usages_operations.py index 594485e6d35ef..dcd38828c5752 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_usages_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._usages_operations import build_list_by_instance_pool_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance_pool( self, resource_group_name: str, @@ -68,38 +74,35 @@ def list_by_instance_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_children is not None: - query_parameters['expandChildren'] = self._serialize.query("expand_children", expand_children, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand_children=expand_children, + template_url=self.list_by_instance_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand_children=expand_children, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsageListResult', pipeline_response) + deserialized = self._deserialize("UsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,6 +120,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py index 303942da530b0..65bbaff961912 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._virtual_clusters_operations import build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_dns_servers_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update_dns_servers( self, resource_group_name: str, @@ -67,27 +73,17 @@ async def update_dns_servers( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.update_dns_servers.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_update_dns_servers_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + template_url=self.update_dns_servers.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def update_dns_servers( return cls(pipeline_response, deserialized, {}) return deserialized + update_dns_servers.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}/updateManagedInstanceDnsServers'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -110,8 +109,10 @@ def list( """Gets a list of all virtualClusters in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualClusterListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualClusterListResult] + :return: An iterator like instance of either VirtualClusterListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualClusterListResult"] @@ -119,34 +120,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualClusterListResult', pipeline_response) + deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -164,11 +160,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -180,8 +178,10 @@ def list_by_resource_group( obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualClusterListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualClusterListResult] + :return: An iterator like instance of either VirtualClusterListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualClusterListResult"] @@ -189,35 +189,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualClusterListResult', pipeline_response) + deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -235,11 +231,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -263,27 +261,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -297,8 +285,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -310,25 +300,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -341,6 +323,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -356,15 +340,17 @@ async def begin_delete( :type virtual_cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -378,21 +364,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -404,6 +383,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore async def _update_initial( @@ -418,32 +398,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'VirtualClusterUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VirtualClusterUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -459,8 +429,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -479,15 +452,19 @@ async def begin_update( :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate :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. + :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 VirtualCluster or the result of cls(response) + :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 VirtualCluster or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualCluster"] lro_delay = kwargs.pop( 'polling_interval', @@ -499,27 +476,21 @@ async def begin_update( resource_group_name=resource_group_name, virtual_cluster_name=virtual_cluster_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualCluster', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -531,4 +502,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py index fe80f720030f7..2f3d0fdbe5d59 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._virtual_network_rules_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'VirtualNetworkRule') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VirtualNetworkRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +152,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -187,15 +178,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule :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. + :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 VirtualNetworkRule or the result of cls(response) + :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 VirtualNetworkRule or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRule"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,28 +203,21 @@ async def begin_create_or_update( server_name=server_name, virtual_network_rule_name=virtual_network_rule_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -241,6 +229,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore async def _delete_initial( @@ -255,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -305,15 +288,17 @@ async def begin_delete( :type virtual_network_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,22 +313,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -355,8 +332,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + @distributed_trace def list_by_server( self, resource_group_name: str, @@ -371,8 +350,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualNetworkRuleListResult] + :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualNetworkRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRuleListResult"] @@ -380,36 +361,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworkRuleListResult', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,6 +405,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_classifiers_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_classifiers_operations.py index 863a75cac1f10..db0470607bd53 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_classifiers_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_classifiers_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._workload_classifiers_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_workload_group_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -76,30 +82,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,8 +109,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -130,35 +128,25 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'WorkloadClassifier') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WorkloadClassifier') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,8 +165,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -207,15 +198,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier :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. + :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 WorkloadClassifier or the result of cls(response) + :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 WorkloadClassifier or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifier"] lro_delay = kwargs.pop( 'polling_interval', @@ -230,30 +225,21 @@ async def begin_create_or_update( workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WorkloadClassifier', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -265,6 +251,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore async def _delete_initial( @@ -281,28 +268,20 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -315,6 +294,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -340,15 +321,17 @@ async def begin_delete( :type workload_classifier_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -365,24 +348,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -394,8 +367,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + @distributed_trace def list_by_workload_group( self, resource_group_name: str, @@ -417,8 +392,10 @@ def list_by_workload_group( classifiers from. :type workload_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadClassifierListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadClassifierListResult] + :return: An iterator like instance of either WorkloadClassifierListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadClassifierListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifierListResult"] @@ -426,38 +403,37 @@ def list_by_workload_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_workload_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_workload_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_workload_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_workload_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkloadClassifierListResult', pipeline_response) + deserialized = self._deserialize("WorkloadClassifierListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -475,6 +451,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_groups_operations.py index f75ce13088373..f886d5307e12a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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.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._workload_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_database_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,29 +78,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -124,34 +122,24 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'WorkloadGroup') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WorkloadGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,8 +158,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -196,15 +187,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.WorkloadGroup :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. + :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 WorkloadGroup or the result of cls(response) + :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 WorkloadGroup or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -218,29 +213,21 @@ async def begin_create_or_update( database_name=database_name, workload_group_name=workload_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WorkloadGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -252,6 +239,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore async def _delete_initial( @@ -267,27 +255,19 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -300,6 +280,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -321,15 +303,17 @@ async def begin_delete( :type workload_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -345,23 +329,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -373,8 +348,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + @distributed_trace def list_by_database( self, resource_group_name: str, @@ -392,7 +369,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadGroupListResult or the result of cls(response) + :return: An iterator like instance of either WorkloadGroupListResult or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -401,37 +379,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkloadGroupListResult', pipeline_response) + deserialized = self._deserialize("WorkloadGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -449,6 +425,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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 0939278d28359..c64585ebd096e 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 @@ -6,696 +6,352 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AdministratorListResult - from ._models_py3 import Advisor - from ._models_py3 import AutoPauseDelayTimeRange - from ._models_py3 import AutomaticTuningOptions - from ._models_py3 import AutomaticTuningServerOptions - from ._models_py3 import AzureADOnlyAuthListResult - from ._models_py3 import BackupShortTermRetentionPolicy - from ._models_py3 import BackupShortTermRetentionPolicyListResult - from ._models_py3 import CheckNameAvailabilityRequest - from ._models_py3 import CheckNameAvailabilityResponse - from ._models_py3 import CompleteDatabaseRestoreDefinition - from ._models_py3 import CopyLongTermRetentionBackupParameters - from ._models_py3 import CreateDatabaseRestorePointDefinition - from ._models_py3 import DataMaskingPolicy - from ._models_py3 import DataMaskingRule - from ._models_py3 import DataMaskingRuleListResult - from ._models_py3 import DataWarehouseUserActivities - from ._models_py3 import DataWarehouseUserActivitiesListResult - from ._models_py3 import Database - from ._models_py3 import DatabaseAutomaticTuning - from ._models_py3 import DatabaseBlobAuditingPolicy - from ._models_py3 import DatabaseBlobAuditingPolicyListResult - from ._models_py3 import DatabaseColumn - from ._models_py3 import DatabaseColumnListResult - from ._models_py3 import DatabaseExtensions - from ._models_py3 import DatabaseIdentity - from ._models_py3 import DatabaseListResult - from ._models_py3 import DatabaseOperation - from ._models_py3 import DatabaseOperationListResult - from ._models_py3 import DatabaseSchema - from ._models_py3 import DatabaseSchemaListResult - from ._models_py3 import DatabaseSecurityAlertListResult - from ._models_py3 import DatabaseSecurityAlertPolicy - from ._models_py3 import DatabaseTable - from ._models_py3 import DatabaseTableListResult - from ._models_py3 import DatabaseUpdate - from ._models_py3 import DatabaseUsage - from ._models_py3 import DatabaseUsageListResult - from ._models_py3 import DatabaseUserIdentity - from ._models_py3 import DatabaseVulnerabilityAssessment - from ._models_py3 import DatabaseVulnerabilityAssessmentListResult - from ._models_py3 import DatabaseVulnerabilityAssessmentRuleBaseline - from ._models_py3 import DatabaseVulnerabilityAssessmentRuleBaselineItem - from ._models_py3 import DatabaseVulnerabilityAssessmentScansExport - from ._models_py3 import Delegation - from ._models_py3 import DeletedServer - from ._models_py3 import DeletedServerListResult - from ._models_py3 import EditionCapability - from ._models_py3 import ElasticPool - from ._models_py3 import ElasticPoolActivity - from ._models_py3 import ElasticPoolActivityListResult - from ._models_py3 import ElasticPoolDatabaseActivity - from ._models_py3 import ElasticPoolDatabaseActivityListResult - from ._models_py3 import ElasticPoolEditionCapability - from ._models_py3 import ElasticPoolListResult - from ._models_py3 import ElasticPoolOperation - from ._models_py3 import ElasticPoolOperationListResult - from ._models_py3 import ElasticPoolPerDatabaseMaxPerformanceLevelCapability - from ._models_py3 import ElasticPoolPerDatabaseMinPerformanceLevelCapability - from ._models_py3 import ElasticPoolPerDatabaseSettings - from ._models_py3 import ElasticPoolPerformanceLevelCapability - from ._models_py3 import ElasticPoolUpdate - from ._models_py3 import EncryptionProtector - from ._models_py3 import EncryptionProtectorListResult - from ._models_py3 import ExportDatabaseDefinition - from ._models_py3 import ExtendedDatabaseBlobAuditingPolicy - from ._models_py3 import ExtendedDatabaseBlobAuditingPolicyListResult - from ._models_py3 import ExtendedServerBlobAuditingPolicy - from ._models_py3 import ExtendedServerBlobAuditingPolicyListResult - from ._models_py3 import FailoverGroup - from ._models_py3 import FailoverGroupListResult - from ._models_py3 import FailoverGroupReadOnlyEndpoint - from ._models_py3 import FailoverGroupReadWriteEndpoint - from ._models_py3 import FailoverGroupUpdate - from ._models_py3 import FirewallRule - from ._models_py3 import FirewallRuleList - from ._models_py3 import FirewallRuleListResult - from ._models_py3 import GeoBackupPolicy - from ._models_py3 import GeoBackupPolicyListResult - from ._models_py3 import ImportExistingDatabaseDefinition - from ._models_py3 import ImportExportExtensionsOperationListResult - from ._models_py3 import ImportExportExtensionsOperationResult - from ._models_py3 import ImportExportOperationResult - from ._models_py3 import ImportNewDatabaseDefinition - from ._models_py3 import InstanceFailoverGroup - from ._models_py3 import InstanceFailoverGroupListResult - from ._models_py3 import InstanceFailoverGroupReadOnlyEndpoint - from ._models_py3 import InstanceFailoverGroupReadWriteEndpoint - from ._models_py3 import InstancePool - from ._models_py3 import InstancePoolEditionCapability - from ._models_py3 import InstancePoolFamilyCapability - from ._models_py3 import InstancePoolListResult - from ._models_py3 import InstancePoolUpdate - from ._models_py3 import InstancePoolVcoresCapability - from ._models_py3 import Job - from ._models_py3 import JobAgent - from ._models_py3 import JobAgentListResult - from ._models_py3 import JobAgentUpdate - from ._models_py3 import JobCredential - from ._models_py3 import JobCredentialListResult - from ._models_py3 import JobExecution - from ._models_py3 import JobExecutionListResult - from ._models_py3 import JobExecutionTarget - from ._models_py3 import JobListResult - from ._models_py3 import JobSchedule - from ._models_py3 import JobStep - from ._models_py3 import JobStepAction - from ._models_py3 import JobStepExecutionOptions - from ._models_py3 import JobStepListResult - from ._models_py3 import JobStepOutput - from ._models_py3 import JobTarget - from ._models_py3 import JobTargetGroup - from ._models_py3 import JobTargetGroupListResult - from ._models_py3 import JobVersion - from ._models_py3 import JobVersionListResult - from ._models_py3 import LedgerDigestUploads - from ._models_py3 import LedgerDigestUploadsListResult - from ._models_py3 import LicenseTypeCapability - from ._models_py3 import LocationCapabilities - from ._models_py3 import LogSizeCapability - from ._models_py3 import LogicalDatabaseTransparentDataEncryption - from ._models_py3 import LogicalDatabaseTransparentDataEncryptionListResult - from ._models_py3 import LogicalServerSecurityAlertPolicyListResult - from ._models_py3 import LongTermRetentionBackup - from ._models_py3 import LongTermRetentionBackupListResult - from ._models_py3 import LongTermRetentionBackupOperationResult - from ._models_py3 import LongTermRetentionPolicy - from ._models_py3 import LongTermRetentionPolicyListResult - from ._models_py3 import MaintenanceConfigurationCapability - from ._models_py3 import MaintenanceWindowOptions - from ._models_py3 import MaintenanceWindowTimeRange - from ._models_py3 import MaintenanceWindows - from ._models_py3 import ManagedBackupShortTermRetentionPolicy - from ._models_py3 import ManagedBackupShortTermRetentionPolicyListResult - from ._models_py3 import ManagedDatabase - from ._models_py3 import ManagedDatabaseListResult - from ._models_py3 import ManagedDatabaseRestoreDetailsResult - from ._models_py3 import ManagedDatabaseSecurityAlertPolicy - from ._models_py3 import ManagedDatabaseSecurityAlertPolicyListResult - from ._models_py3 import ManagedDatabaseUpdate - from ._models_py3 import ManagedInstance - from ._models_py3 import ManagedInstanceAdministrator - from ._models_py3 import ManagedInstanceAdministratorListResult - from ._models_py3 import ManagedInstanceAzureADOnlyAuthListResult - from ._models_py3 import ManagedInstanceAzureADOnlyAuthentication - from ._models_py3 import ManagedInstanceEditionCapability - from ._models_py3 import ManagedInstanceEncryptionProtector - from ._models_py3 import ManagedInstanceEncryptionProtectorListResult - from ._models_py3 import ManagedInstanceExternalAdministrator - from ._models_py3 import ManagedInstanceFamilyCapability - from ._models_py3 import ManagedInstanceKey - from ._models_py3 import ManagedInstanceKeyListResult - from ._models_py3 import ManagedInstanceListResult - from ._models_py3 import ManagedInstanceLongTermRetentionBackup - from ._models_py3 import ManagedInstanceLongTermRetentionBackupListResult - from ._models_py3 import ManagedInstanceLongTermRetentionPolicy - from ._models_py3 import ManagedInstanceLongTermRetentionPolicyListResult - from ._models_py3 import ManagedInstanceMaintenanceConfigurationCapability - from ._models_py3 import ManagedInstanceOperation - from ._models_py3 import ManagedInstanceOperationListResult - from ._models_py3 import ManagedInstanceOperationParametersPair - from ._models_py3 import ManagedInstanceOperationSteps - from ._models_py3 import ManagedInstancePairInfo - from ._models_py3 import ManagedInstancePecProperty - from ._models_py3 import ManagedInstancePrivateEndpointConnection - from ._models_py3 import ManagedInstancePrivateEndpointConnectionListResult - from ._models_py3 import ManagedInstancePrivateEndpointConnectionProperties - from ._models_py3 import ManagedInstancePrivateEndpointProperty - from ._models_py3 import ManagedInstancePrivateLink - from ._models_py3 import ManagedInstancePrivateLinkListResult - from ._models_py3 import ManagedInstancePrivateLinkProperties - from ._models_py3 import ManagedInstancePrivateLinkServiceConnectionStateProperty - from ._models_py3 import ManagedInstanceQuery - from ._models_py3 import ManagedInstanceQueryStatistics - from ._models_py3 import ManagedInstanceUpdate - from ._models_py3 import ManagedInstanceVcoresCapability - from ._models_py3 import ManagedInstanceVersionCapability - from ._models_py3 import ManagedInstanceVulnerabilityAssessment - from ._models_py3 import ManagedInstanceVulnerabilityAssessmentListResult - from ._models_py3 import ManagedServerSecurityAlertPolicy - from ._models_py3 import ManagedServerSecurityAlertPolicyListResult - from ._models_py3 import ManagedTransparentDataEncryption - from ._models_py3 import ManagedTransparentDataEncryptionListResult - from ._models_py3 import MaxSizeCapability - from ._models_py3 import MaxSizeRangeCapability - from ._models_py3 import Metric - from ._models_py3 import MetricAvailability - from ._models_py3 import MetricDefinition - from ._models_py3 import MetricDefinitionListResult - from ._models_py3 import MetricListResult - from ._models_py3 import MetricName - from ._models_py3 import MetricValue - from ._models_py3 import MinCapacityCapability - from ._models_py3 import Name - from ._models_py3 import NetworkIsolationSettings - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationImpact - from ._models_py3 import OperationListResult - from ._models_py3 import OperationsHealth - from ._models_py3 import OperationsHealthListResult - from ._models_py3 import OutboundFirewallRule - from ._models_py3 import OutboundFirewallRuleListResult - from ._models_py3 import PartnerInfo - from ._models_py3 import PartnerRegionInfo - from ._models_py3 import PerformanceLevelCapability - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateEndpointConnectionProperties - from ._models_py3 import PrivateEndpointConnectionRequestStatus - from ._models_py3 import PrivateEndpointProperty - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceListResult - from ._models_py3 import PrivateLinkResourceProperties - from ._models_py3 import PrivateLinkServiceConnectionStateProperty - from ._models_py3 import ProxyResource - from ._models_py3 import ProxyResourceWithWritableName - from ._models_py3 import QueryMetricInterval - from ._models_py3 import QueryMetricProperties - from ._models_py3 import QueryStatistics - from ._models_py3 import QueryStatisticsProperties - from ._models_py3 import ReadScaleCapability - from ._models_py3 import RecommendedAction - from ._models_py3 import RecommendedActionErrorInfo - from ._models_py3 import RecommendedActionImpactRecord - from ._models_py3 import RecommendedActionImplementationInfo - from ._models_py3 import RecommendedActionMetricInfo - from ._models_py3 import RecommendedActionStateInfo - from ._models_py3 import RecommendedSensitivityLabelUpdate - from ._models_py3 import RecommendedSensitivityLabelUpdateList - from ._models_py3 import RecoverableDatabase - from ._models_py3 import RecoverableDatabaseListResult - from ._models_py3 import RecoverableManagedDatabase - from ._models_py3 import RecoverableManagedDatabaseListResult - from ._models_py3 import ReplicationLink - from ._models_py3 import ReplicationLinkListResult - from ._models_py3 import Resource - from ._models_py3 import ResourceIdentity - from ._models_py3 import ResourceMoveDefinition - from ._models_py3 import ResourceWithWritableName - from ._models_py3 import RestorableDroppedDatabase - from ._models_py3 import RestorableDroppedDatabaseListResult - from ._models_py3 import RestorableDroppedManagedDatabase - from ._models_py3 import RestorableDroppedManagedDatabaseListResult - from ._models_py3 import RestorePoint - from ._models_py3 import RestorePointListResult - from ._models_py3 import SecurityEvent - from ._models_py3 import SecurityEventCollection - from ._models_py3 import SecurityEventSqlInjectionAdditionalProperties - from ._models_py3 import SecurityEventsFilterParameters - from ._models_py3 import SensitivityLabel - from ._models_py3 import SensitivityLabelListResult - from ._models_py3 import SensitivityLabelUpdate - from ._models_py3 import SensitivityLabelUpdateList - from ._models_py3 import Server - from ._models_py3 import ServerAutomaticTuning - from ._models_py3 import ServerAzureADAdministrator - from ._models_py3 import ServerAzureADOnlyAuthentication - from ._models_py3 import ServerBlobAuditingPolicy - from ._models_py3 import ServerBlobAuditingPolicyListResult - from ._models_py3 import ServerCommunicationLink - from ._models_py3 import ServerCommunicationLinkListResult - from ._models_py3 import ServerConnectionPolicy - from ._models_py3 import ServerConnectionPolicyListResult - from ._models_py3 import ServerDevOpsAuditSettingsListResult - from ._models_py3 import ServerDevOpsAuditingSettings - from ._models_py3 import ServerDnsAlias - from ._models_py3 import ServerDnsAliasAcquisition - from ._models_py3 import ServerDnsAliasListResult - from ._models_py3 import ServerExternalAdministrator - from ._models_py3 import ServerInfo - from ._models_py3 import ServerKey - from ._models_py3 import ServerKeyListResult - from ._models_py3 import ServerListResult - from ._models_py3 import ServerOperation - from ._models_py3 import ServerOperationListResult - from ._models_py3 import ServerPrivateEndpointConnection - from ._models_py3 import ServerSecurityAlertPolicy - from ._models_py3 import ServerTrustGroup - from ._models_py3 import ServerTrustGroupListResult - from ._models_py3 import ServerUpdate - from ._models_py3 import ServerUsage - from ._models_py3 import ServerUsageListResult - from ._models_py3 import ServerVersionCapability - from ._models_py3 import ServerVulnerabilityAssessment - from ._models_py3 import ServerVulnerabilityAssessmentListResult - from ._models_py3 import ServiceObjective - from ._models_py3 import ServiceObjectiveCapability - from ._models_py3 import ServiceObjectiveListResult - from ._models_py3 import ServicePrincipal - from ._models_py3 import Sku - from ._models_py3 import SloUsageMetric - from ._models_py3 import SqlAgentConfiguration - from ._models_py3 import StorageCapability - from ._models_py3 import SubscriptionUsage - from ._models_py3 import SubscriptionUsageListResult - from ._models_py3 import SyncAgent - from ._models_py3 import SyncAgentKeyProperties - from ._models_py3 import SyncAgentLinkedDatabase - from ._models_py3 import SyncAgentLinkedDatabaseListResult - from ._models_py3 import SyncAgentListResult - from ._models_py3 import SyncDatabaseIdListResult - from ._models_py3 import SyncDatabaseIdProperties - from ._models_py3 import SyncFullSchemaProperties - from ._models_py3 import SyncFullSchemaPropertiesListResult - from ._models_py3 import SyncFullSchemaTable - from ._models_py3 import SyncFullSchemaTableColumn - from ._models_py3 import SyncGroup - from ._models_py3 import SyncGroupListResult - from ._models_py3 import SyncGroupLogListResult - from ._models_py3 import SyncGroupLogProperties - from ._models_py3 import SyncGroupSchema - from ._models_py3 import SyncGroupSchemaTable - from ._models_py3 import SyncGroupSchemaTableColumn - from ._models_py3 import SyncMember - from ._models_py3 import SyncMemberListResult - from ._models_py3 import SystemData - from ._models_py3 import TdeCertificate - from ._models_py3 import TimeZone - from ._models_py3 import TimeZoneListResult - from ._models_py3 import TopQueries - from ._models_py3 import TopQueriesListResult - from ._models_py3 import TrackedResource - from ._models_py3 import UnlinkParameters - from ._models_py3 import UpdateLongTermRetentionBackupParameters - from ._models_py3 import UpdateManagedInstanceDnsServersOperation - from ._models_py3 import UpsertManagedServerOperationParameters - from ._models_py3 import UpsertManagedServerOperationStep - from ._models_py3 import Usage - from ._models_py3 import UsageListResult - from ._models_py3 import UserIdentity - from ._models_py3 import VirtualCluster - from ._models_py3 import VirtualClusterListResult - from ._models_py3 import VirtualClusterUpdate - from ._models_py3 import VirtualNetworkRule - from ._models_py3 import VirtualNetworkRuleListResult - from ._models_py3 import VulnerabilityAssessmentRecurringScansProperties - from ._models_py3 import VulnerabilityAssessmentScanError - from ._models_py3 import VulnerabilityAssessmentScanRecord - from ._models_py3 import VulnerabilityAssessmentScanRecordListResult - from ._models_py3 import WorkloadClassifier - from ._models_py3 import WorkloadClassifierListResult - from ._models_py3 import WorkloadGroup - from ._models_py3 import WorkloadGroupListResult -except (SyntaxError, ImportError): - from ._models import AdministratorListResult # type: ignore - from ._models import Advisor # type: ignore - from ._models import AutoPauseDelayTimeRange # type: ignore - from ._models import AutomaticTuningOptions # type: ignore - from ._models import AutomaticTuningServerOptions # type: ignore - from ._models import AzureADOnlyAuthListResult # type: ignore - from ._models import BackupShortTermRetentionPolicy # type: ignore - from ._models import BackupShortTermRetentionPolicyListResult # type: ignore - from ._models import CheckNameAvailabilityRequest # type: ignore - from ._models import CheckNameAvailabilityResponse # type: ignore - from ._models import CompleteDatabaseRestoreDefinition # type: ignore - from ._models import CopyLongTermRetentionBackupParameters # type: ignore - from ._models import CreateDatabaseRestorePointDefinition # type: ignore - from ._models import DataMaskingPolicy # type: ignore - from ._models import DataMaskingRule # type: ignore - from ._models import DataMaskingRuleListResult # type: ignore - from ._models import DataWarehouseUserActivities # type: ignore - from ._models import DataWarehouseUserActivitiesListResult # type: ignore - from ._models import Database # type: ignore - from ._models import DatabaseAutomaticTuning # type: ignore - from ._models import DatabaseBlobAuditingPolicy # type: ignore - from ._models import DatabaseBlobAuditingPolicyListResult # type: ignore - from ._models import DatabaseColumn # type: ignore - from ._models import DatabaseColumnListResult # type: ignore - from ._models import DatabaseExtensions # type: ignore - from ._models import DatabaseIdentity # type: ignore - from ._models import DatabaseListResult # type: ignore - from ._models import DatabaseOperation # type: ignore - from ._models import DatabaseOperationListResult # type: ignore - from ._models import DatabaseSchema # type: ignore - from ._models import DatabaseSchemaListResult # type: ignore - from ._models import DatabaseSecurityAlertListResult # type: ignore - from ._models import DatabaseSecurityAlertPolicy # type: ignore - from ._models import DatabaseTable # type: ignore - from ._models import DatabaseTableListResult # type: ignore - from ._models import DatabaseUpdate # type: ignore - from ._models import DatabaseUsage # type: ignore - from ._models import DatabaseUsageListResult # type: ignore - from ._models import DatabaseUserIdentity # type: ignore - from ._models import DatabaseVulnerabilityAssessment # type: ignore - from ._models import DatabaseVulnerabilityAssessmentListResult # type: ignore - from ._models import DatabaseVulnerabilityAssessmentRuleBaseline # type: ignore - from ._models import DatabaseVulnerabilityAssessmentRuleBaselineItem # type: ignore - from ._models import DatabaseVulnerabilityAssessmentScansExport # type: ignore - from ._models import Delegation # type: ignore - from ._models import DeletedServer # type: ignore - from ._models import DeletedServerListResult # type: ignore - from ._models import EditionCapability # type: ignore - from ._models import ElasticPool # type: ignore - from ._models import ElasticPoolActivity # type: ignore - from ._models import ElasticPoolActivityListResult # type: ignore - from ._models import ElasticPoolDatabaseActivity # type: ignore - from ._models import ElasticPoolDatabaseActivityListResult # type: ignore - from ._models import ElasticPoolEditionCapability # type: ignore - from ._models import ElasticPoolListResult # type: ignore - from ._models import ElasticPoolOperation # type: ignore - from ._models import ElasticPoolOperationListResult # type: ignore - from ._models import ElasticPoolPerDatabaseMaxPerformanceLevelCapability # type: ignore - from ._models import ElasticPoolPerDatabaseMinPerformanceLevelCapability # type: ignore - from ._models import ElasticPoolPerDatabaseSettings # type: ignore - from ._models import ElasticPoolPerformanceLevelCapability # type: ignore - from ._models import ElasticPoolUpdate # type: ignore - from ._models import EncryptionProtector # type: ignore - from ._models import EncryptionProtectorListResult # type: ignore - from ._models import ExportDatabaseDefinition # type: ignore - from ._models import ExtendedDatabaseBlobAuditingPolicy # type: ignore - from ._models import ExtendedDatabaseBlobAuditingPolicyListResult # type: ignore - from ._models import ExtendedServerBlobAuditingPolicy # type: ignore - from ._models import ExtendedServerBlobAuditingPolicyListResult # type: ignore - from ._models import FailoverGroup # type: ignore - from ._models import FailoverGroupListResult # type: ignore - from ._models import FailoverGroupReadOnlyEndpoint # type: ignore - from ._models import FailoverGroupReadWriteEndpoint # type: ignore - from ._models import FailoverGroupUpdate # type: ignore - from ._models import FirewallRule # type: ignore - from ._models import FirewallRuleList # type: ignore - from ._models import FirewallRuleListResult # type: ignore - from ._models import GeoBackupPolicy # type: ignore - from ._models import GeoBackupPolicyListResult # type: ignore - from ._models import ImportExistingDatabaseDefinition # type: ignore - from ._models import ImportExportExtensionsOperationListResult # type: ignore - from ._models import ImportExportExtensionsOperationResult # type: ignore - from ._models import ImportExportOperationResult # type: ignore - from ._models import ImportNewDatabaseDefinition # type: ignore - from ._models import InstanceFailoverGroup # type: ignore - from ._models import InstanceFailoverGroupListResult # type: ignore - from ._models import InstanceFailoverGroupReadOnlyEndpoint # type: ignore - from ._models import InstanceFailoverGroupReadWriteEndpoint # type: ignore - from ._models import InstancePool # type: ignore - from ._models import InstancePoolEditionCapability # type: ignore - from ._models import InstancePoolFamilyCapability # type: ignore - from ._models import InstancePoolListResult # type: ignore - from ._models import InstancePoolUpdate # type: ignore - from ._models import InstancePoolVcoresCapability # type: ignore - from ._models import Job # type: ignore - from ._models import JobAgent # type: ignore - from ._models import JobAgentListResult # type: ignore - from ._models import JobAgentUpdate # type: ignore - from ._models import JobCredential # type: ignore - from ._models import JobCredentialListResult # type: ignore - from ._models import JobExecution # type: ignore - from ._models import JobExecutionListResult # type: ignore - from ._models import JobExecutionTarget # type: ignore - from ._models import JobListResult # type: ignore - from ._models import JobSchedule # type: ignore - from ._models import JobStep # type: ignore - from ._models import JobStepAction # type: ignore - from ._models import JobStepExecutionOptions # type: ignore - from ._models import JobStepListResult # type: ignore - from ._models import JobStepOutput # type: ignore - from ._models import JobTarget # type: ignore - from ._models import JobTargetGroup # type: ignore - from ._models import JobTargetGroupListResult # type: ignore - from ._models import JobVersion # type: ignore - from ._models import JobVersionListResult # type: ignore - from ._models import LedgerDigestUploads # type: ignore - from ._models import LedgerDigestUploadsListResult # type: ignore - from ._models import LicenseTypeCapability # type: ignore - from ._models import LocationCapabilities # type: ignore - from ._models import LogSizeCapability # type: ignore - from ._models import LogicalDatabaseTransparentDataEncryption # type: ignore - from ._models import LogicalDatabaseTransparentDataEncryptionListResult # type: ignore - from ._models import LogicalServerSecurityAlertPolicyListResult # type: ignore - from ._models import LongTermRetentionBackup # type: ignore - from ._models import LongTermRetentionBackupListResult # type: ignore - from ._models import LongTermRetentionBackupOperationResult # type: ignore - from ._models import LongTermRetentionPolicy # type: ignore - from ._models import LongTermRetentionPolicyListResult # type: ignore - from ._models import MaintenanceConfigurationCapability # type: ignore - from ._models import MaintenanceWindowOptions # type: ignore - from ._models import MaintenanceWindowTimeRange # type: ignore - from ._models import MaintenanceWindows # type: ignore - from ._models import ManagedBackupShortTermRetentionPolicy # type: ignore - from ._models import ManagedBackupShortTermRetentionPolicyListResult # type: ignore - from ._models import ManagedDatabase # type: ignore - from ._models import ManagedDatabaseListResult # type: ignore - from ._models import ManagedDatabaseRestoreDetailsResult # type: ignore - from ._models import ManagedDatabaseSecurityAlertPolicy # type: ignore - from ._models import ManagedDatabaseSecurityAlertPolicyListResult # type: ignore - from ._models import ManagedDatabaseUpdate # type: ignore - from ._models import ManagedInstance # type: ignore - from ._models import ManagedInstanceAdministrator # type: ignore - from ._models import ManagedInstanceAdministratorListResult # type: ignore - from ._models import ManagedInstanceAzureADOnlyAuthListResult # type: ignore - from ._models import ManagedInstanceAzureADOnlyAuthentication # type: ignore - from ._models import ManagedInstanceEditionCapability # type: ignore - from ._models import ManagedInstanceEncryptionProtector # type: ignore - from ._models import ManagedInstanceEncryptionProtectorListResult # type: ignore - from ._models import ManagedInstanceExternalAdministrator # type: ignore - from ._models import ManagedInstanceFamilyCapability # type: ignore - from ._models import ManagedInstanceKey # type: ignore - from ._models import ManagedInstanceKeyListResult # type: ignore - from ._models import ManagedInstanceListResult # type: ignore - from ._models import ManagedInstanceLongTermRetentionBackup # type: ignore - from ._models import ManagedInstanceLongTermRetentionBackupListResult # type: ignore - from ._models import ManagedInstanceLongTermRetentionPolicy # type: ignore - from ._models import ManagedInstanceLongTermRetentionPolicyListResult # type: ignore - from ._models import ManagedInstanceMaintenanceConfigurationCapability # type: ignore - from ._models import ManagedInstanceOperation # type: ignore - from ._models import ManagedInstanceOperationListResult # type: ignore - from ._models import ManagedInstanceOperationParametersPair # type: ignore - from ._models import ManagedInstanceOperationSteps # type: ignore - from ._models import ManagedInstancePairInfo # type: ignore - from ._models import ManagedInstancePecProperty # type: ignore - from ._models import ManagedInstancePrivateEndpointConnection # type: ignore - from ._models import ManagedInstancePrivateEndpointConnectionListResult # type: ignore - from ._models import ManagedInstancePrivateEndpointConnectionProperties # type: ignore - from ._models import ManagedInstancePrivateEndpointProperty # type: ignore - from ._models import ManagedInstancePrivateLink # type: ignore - from ._models import ManagedInstancePrivateLinkListResult # type: ignore - from ._models import ManagedInstancePrivateLinkProperties # type: ignore - from ._models import ManagedInstancePrivateLinkServiceConnectionStateProperty # type: ignore - from ._models import ManagedInstanceQuery # type: ignore - from ._models import ManagedInstanceQueryStatistics # type: ignore - from ._models import ManagedInstanceUpdate # type: ignore - from ._models import ManagedInstanceVcoresCapability # type: ignore - from ._models import ManagedInstanceVersionCapability # type: ignore - from ._models import ManagedInstanceVulnerabilityAssessment # type: ignore - from ._models import ManagedInstanceVulnerabilityAssessmentListResult # type: ignore - from ._models import ManagedServerSecurityAlertPolicy # type: ignore - from ._models import ManagedServerSecurityAlertPolicyListResult # type: ignore - from ._models import ManagedTransparentDataEncryption # type: ignore - from ._models import ManagedTransparentDataEncryptionListResult # type: ignore - from ._models import MaxSizeCapability # type: ignore - from ._models import MaxSizeRangeCapability # type: ignore - from ._models import Metric # type: ignore - from ._models import MetricAvailability # type: ignore - from ._models import MetricDefinition # type: ignore - from ._models import MetricDefinitionListResult # type: ignore - from ._models import MetricListResult # type: ignore - from ._models import MetricName # type: ignore - from ._models import MetricValue # type: ignore - from ._models import MinCapacityCapability # type: ignore - from ._models import Name # type: ignore - from ._models import NetworkIsolationSettings # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationImpact # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OperationsHealth # type: ignore - from ._models import OperationsHealthListResult # type: ignore - from ._models import OutboundFirewallRule # type: ignore - from ._models import OutboundFirewallRuleListResult # type: ignore - from ._models import PartnerInfo # type: ignore - from ._models import PartnerRegionInfo # type: ignore - from ._models import PerformanceLevelCapability # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateEndpointConnectionProperties # type: ignore - from ._models import PrivateEndpointConnectionRequestStatus # type: ignore - from ._models import PrivateEndpointProperty # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceListResult # type: ignore - from ._models import PrivateLinkResourceProperties # type: ignore - from ._models import PrivateLinkServiceConnectionStateProperty # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import ProxyResourceWithWritableName # type: ignore - from ._models import QueryMetricInterval # type: ignore - from ._models import QueryMetricProperties # type: ignore - from ._models import QueryStatistics # type: ignore - from ._models import QueryStatisticsProperties # type: ignore - from ._models import ReadScaleCapability # type: ignore - from ._models import RecommendedAction # type: ignore - from ._models import RecommendedActionErrorInfo # type: ignore - from ._models import RecommendedActionImpactRecord # type: ignore - from ._models import RecommendedActionImplementationInfo # type: ignore - from ._models import RecommendedActionMetricInfo # type: ignore - from ._models import RecommendedActionStateInfo # type: ignore - from ._models import RecommendedSensitivityLabelUpdate # type: ignore - from ._models import RecommendedSensitivityLabelUpdateList # type: ignore - from ._models import RecoverableDatabase # type: ignore - from ._models import RecoverableDatabaseListResult # type: ignore - from ._models import RecoverableManagedDatabase # type: ignore - from ._models import RecoverableManagedDatabaseListResult # type: ignore - from ._models import ReplicationLink # type: ignore - from ._models import ReplicationLinkListResult # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceIdentity # type: ignore - from ._models import ResourceMoveDefinition # type: ignore - from ._models import ResourceWithWritableName # type: ignore - from ._models import RestorableDroppedDatabase # type: ignore - from ._models import RestorableDroppedDatabaseListResult # type: ignore - from ._models import RestorableDroppedManagedDatabase # type: ignore - from ._models import RestorableDroppedManagedDatabaseListResult # type: ignore - from ._models import RestorePoint # type: ignore - from ._models import RestorePointListResult # type: ignore - from ._models import SecurityEvent # type: ignore - from ._models import SecurityEventCollection # type: ignore - from ._models import SecurityEventSqlInjectionAdditionalProperties # type: ignore - from ._models import SecurityEventsFilterParameters # type: ignore - from ._models import SensitivityLabel # type: ignore - from ._models import SensitivityLabelListResult # type: ignore - from ._models import SensitivityLabelUpdate # type: ignore - from ._models import SensitivityLabelUpdateList # type: ignore - from ._models import Server # type: ignore - from ._models import ServerAutomaticTuning # type: ignore - from ._models import ServerAzureADAdministrator # type: ignore - from ._models import ServerAzureADOnlyAuthentication # type: ignore - from ._models import ServerBlobAuditingPolicy # type: ignore - from ._models import ServerBlobAuditingPolicyListResult # type: ignore - from ._models import ServerCommunicationLink # type: ignore - from ._models import ServerCommunicationLinkListResult # type: ignore - from ._models import ServerConnectionPolicy # type: ignore - from ._models import ServerConnectionPolicyListResult # type: ignore - from ._models import ServerDevOpsAuditSettingsListResult # type: ignore - from ._models import ServerDevOpsAuditingSettings # type: ignore - from ._models import ServerDnsAlias # type: ignore - from ._models import ServerDnsAliasAcquisition # type: ignore - from ._models import ServerDnsAliasListResult # type: ignore - from ._models import ServerExternalAdministrator # type: ignore - from ._models import ServerInfo # type: ignore - from ._models import ServerKey # type: ignore - from ._models import ServerKeyListResult # type: ignore - from ._models import ServerListResult # type: ignore - from ._models import ServerOperation # type: ignore - from ._models import ServerOperationListResult # type: ignore - from ._models import ServerPrivateEndpointConnection # type: ignore - from ._models import ServerSecurityAlertPolicy # type: ignore - from ._models import ServerTrustGroup # type: ignore - from ._models import ServerTrustGroupListResult # type: ignore - from ._models import ServerUpdate # type: ignore - from ._models import ServerUsage # type: ignore - from ._models import ServerUsageListResult # type: ignore - from ._models import ServerVersionCapability # type: ignore - from ._models import ServerVulnerabilityAssessment # type: ignore - from ._models import ServerVulnerabilityAssessmentListResult # type: ignore - from ._models import ServiceObjective # type: ignore - from ._models import ServiceObjectiveCapability # type: ignore - from ._models import ServiceObjectiveListResult # type: ignore - from ._models import ServicePrincipal # type: ignore - from ._models import Sku # type: ignore - from ._models import SloUsageMetric # type: ignore - from ._models import SqlAgentConfiguration # type: ignore - from ._models import StorageCapability # type: ignore - from ._models import SubscriptionUsage # type: ignore - from ._models import SubscriptionUsageListResult # type: ignore - from ._models import SyncAgent # type: ignore - from ._models import SyncAgentKeyProperties # type: ignore - from ._models import SyncAgentLinkedDatabase # type: ignore - from ._models import SyncAgentLinkedDatabaseListResult # type: ignore - from ._models import SyncAgentListResult # type: ignore - from ._models import SyncDatabaseIdListResult # type: ignore - from ._models import SyncDatabaseIdProperties # type: ignore - from ._models import SyncFullSchemaProperties # type: ignore - from ._models import SyncFullSchemaPropertiesListResult # type: ignore - from ._models import SyncFullSchemaTable # type: ignore - from ._models import SyncFullSchemaTableColumn # type: ignore - from ._models import SyncGroup # type: ignore - from ._models import SyncGroupListResult # type: ignore - from ._models import SyncGroupLogListResult # type: ignore - from ._models import SyncGroupLogProperties # type: ignore - from ._models import SyncGroupSchema # type: ignore - from ._models import SyncGroupSchemaTable # type: ignore - from ._models import SyncGroupSchemaTableColumn # type: ignore - from ._models import SyncMember # type: ignore - from ._models import SyncMemberListResult # type: ignore - from ._models import SystemData # type: ignore - from ._models import TdeCertificate # type: ignore - from ._models import TimeZone # type: ignore - from ._models import TimeZoneListResult # type: ignore - from ._models import TopQueries # type: ignore - from ._models import TopQueriesListResult # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import UnlinkParameters # type: ignore - from ._models import UpdateLongTermRetentionBackupParameters # type: ignore - from ._models import UpdateManagedInstanceDnsServersOperation # type: ignore - from ._models import UpsertManagedServerOperationParameters # type: ignore - from ._models import UpsertManagedServerOperationStep # type: ignore - from ._models import Usage # type: ignore - from ._models import UsageListResult # type: ignore - from ._models import UserIdentity # type: ignore - from ._models import VirtualCluster # type: ignore - from ._models import VirtualClusterListResult # type: ignore - from ._models import VirtualClusterUpdate # type: ignore - from ._models import VirtualNetworkRule # type: ignore - from ._models import VirtualNetworkRuleListResult # type: ignore - from ._models import VulnerabilityAssessmentRecurringScansProperties # type: ignore - from ._models import VulnerabilityAssessmentScanError # type: ignore - from ._models import VulnerabilityAssessmentScanRecord # type: ignore - from ._models import VulnerabilityAssessmentScanRecordListResult # type: ignore - from ._models import WorkloadClassifier # type: ignore - from ._models import WorkloadClassifierListResult # type: ignore - from ._models import WorkloadGroup # type: ignore - from ._models import WorkloadGroupListResult # type: ignore +from ._models_py3 import AdministratorListResult +from ._models_py3 import Advisor +from ._models_py3 import AutoPauseDelayTimeRange +from ._models_py3 import AutomaticTuningOptions +from ._models_py3 import AutomaticTuningServerOptions +from ._models_py3 import AzureADOnlyAuthListResult +from ._models_py3 import BackupShortTermRetentionPolicy +from ._models_py3 import BackupShortTermRetentionPolicyListResult +from ._models_py3 import CheckNameAvailabilityRequest +from ._models_py3 import CheckNameAvailabilityResponse +from ._models_py3 import CompleteDatabaseRestoreDefinition +from ._models_py3 import CopyLongTermRetentionBackupParameters +from ._models_py3 import CreateDatabaseRestorePointDefinition +from ._models_py3 import DataMaskingPolicy +from ._models_py3 import DataMaskingRule +from ._models_py3 import DataMaskingRuleListResult +from ._models_py3 import DataWarehouseUserActivities +from ._models_py3 import DataWarehouseUserActivitiesListResult +from ._models_py3 import Database +from ._models_py3 import DatabaseAutomaticTuning +from ._models_py3 import DatabaseBlobAuditingPolicy +from ._models_py3 import DatabaseBlobAuditingPolicyListResult +from ._models_py3 import DatabaseColumn +from ._models_py3 import DatabaseColumnListResult +from ._models_py3 import DatabaseExtensions +from ._models_py3 import DatabaseIdentity +from ._models_py3 import DatabaseListResult +from ._models_py3 import DatabaseOperation +from ._models_py3 import DatabaseOperationListResult +from ._models_py3 import DatabaseSchema +from ._models_py3 import DatabaseSchemaListResult +from ._models_py3 import DatabaseSecurityAlertListResult +from ._models_py3 import DatabaseSecurityAlertPolicy +from ._models_py3 import DatabaseTable +from ._models_py3 import DatabaseTableListResult +from ._models_py3 import DatabaseUpdate +from ._models_py3 import DatabaseUsage +from ._models_py3 import DatabaseUsageListResult +from ._models_py3 import DatabaseUserIdentity +from ._models_py3 import DatabaseVulnerabilityAssessment +from ._models_py3 import DatabaseVulnerabilityAssessmentListResult +from ._models_py3 import DatabaseVulnerabilityAssessmentRuleBaseline +from ._models_py3 import DatabaseVulnerabilityAssessmentRuleBaselineItem +from ._models_py3 import DatabaseVulnerabilityAssessmentScansExport +from ._models_py3 import Delegation +from ._models_py3 import DeletedServer +from ._models_py3 import DeletedServerListResult +from ._models_py3 import EditionCapability +from ._models_py3 import ElasticPool +from ._models_py3 import ElasticPoolActivity +from ._models_py3 import ElasticPoolActivityListResult +from ._models_py3 import ElasticPoolDatabaseActivity +from ._models_py3 import ElasticPoolDatabaseActivityListResult +from ._models_py3 import ElasticPoolEditionCapability +from ._models_py3 import ElasticPoolListResult +from ._models_py3 import ElasticPoolOperation +from ._models_py3 import ElasticPoolOperationListResult +from ._models_py3 import ElasticPoolPerDatabaseMaxPerformanceLevelCapability +from ._models_py3 import ElasticPoolPerDatabaseMinPerformanceLevelCapability +from ._models_py3 import ElasticPoolPerDatabaseSettings +from ._models_py3 import ElasticPoolPerformanceLevelCapability +from ._models_py3 import ElasticPoolUpdate +from ._models_py3 import EncryptionProtector +from ._models_py3 import EncryptionProtectorListResult +from ._models_py3 import ExportDatabaseDefinition +from ._models_py3 import ExtendedDatabaseBlobAuditingPolicy +from ._models_py3 import ExtendedDatabaseBlobAuditingPolicyListResult +from ._models_py3 import ExtendedServerBlobAuditingPolicy +from ._models_py3 import ExtendedServerBlobAuditingPolicyListResult +from ._models_py3 import FailoverGroup +from ._models_py3 import FailoverGroupListResult +from ._models_py3 import FailoverGroupReadOnlyEndpoint +from ._models_py3 import FailoverGroupReadWriteEndpoint +from ._models_py3 import FailoverGroupUpdate +from ._models_py3 import FirewallRule +from ._models_py3 import FirewallRuleList +from ._models_py3 import FirewallRuleListResult +from ._models_py3 import GeoBackupPolicy +from ._models_py3 import GeoBackupPolicyListResult +from ._models_py3 import IPv6FirewallRule +from ._models_py3 import IPv6FirewallRuleList +from ._models_py3 import IPv6FirewallRuleListResult +from ._models_py3 import ImportExistingDatabaseDefinition +from ._models_py3 import ImportExportExtensionsOperationListResult +from ._models_py3 import ImportExportExtensionsOperationResult +from ._models_py3 import ImportExportOperationResult +from ._models_py3 import ImportNewDatabaseDefinition +from ._models_py3 import InstanceFailoverGroup +from ._models_py3 import InstanceFailoverGroupListResult +from ._models_py3 import InstanceFailoverGroupReadOnlyEndpoint +from ._models_py3 import InstanceFailoverGroupReadWriteEndpoint +from ._models_py3 import InstancePool +from ._models_py3 import InstancePoolEditionCapability +from ._models_py3 import InstancePoolFamilyCapability +from ._models_py3 import InstancePoolListResult +from ._models_py3 import InstancePoolUpdate +from ._models_py3 import InstancePoolVcoresCapability +from ._models_py3 import Job +from ._models_py3 import JobAgent +from ._models_py3 import JobAgentListResult +from ._models_py3 import JobAgentUpdate +from ._models_py3 import JobCredential +from ._models_py3 import JobCredentialListResult +from ._models_py3 import JobExecution +from ._models_py3 import JobExecutionListResult +from ._models_py3 import JobExecutionTarget +from ._models_py3 import JobListResult +from ._models_py3 import JobSchedule +from ._models_py3 import JobStep +from ._models_py3 import JobStepAction +from ._models_py3 import JobStepExecutionOptions +from ._models_py3 import JobStepListResult +from ._models_py3 import JobStepOutput +from ._models_py3 import JobTarget +from ._models_py3 import JobTargetGroup +from ._models_py3 import JobTargetGroupListResult +from ._models_py3 import JobVersion +from ._models_py3 import JobVersionListResult +from ._models_py3 import LedgerDigestUploads +from ._models_py3 import LedgerDigestUploadsListResult +from ._models_py3 import LicenseTypeCapability +from ._models_py3 import LocationCapabilities +from ._models_py3 import LogSizeCapability +from ._models_py3 import LogicalDatabaseTransparentDataEncryption +from ._models_py3 import LogicalDatabaseTransparentDataEncryptionListResult +from ._models_py3 import LogicalServerSecurityAlertPolicyListResult +from ._models_py3 import LongTermRetentionBackup +from ._models_py3 import LongTermRetentionBackupListResult +from ._models_py3 import LongTermRetentionBackupOperationResult +from ._models_py3 import LongTermRetentionPolicy +from ._models_py3 import LongTermRetentionPolicyListResult +from ._models_py3 import MaintenanceConfigurationCapability +from ._models_py3 import MaintenanceWindowOptions +from ._models_py3 import MaintenanceWindowTimeRange +from ._models_py3 import MaintenanceWindows +from ._models_py3 import ManagedBackupShortTermRetentionPolicy +from ._models_py3 import ManagedBackupShortTermRetentionPolicyListResult +from ._models_py3 import ManagedDatabase +from ._models_py3 import ManagedDatabaseListResult +from ._models_py3 import ManagedDatabaseRestoreDetailsResult +from ._models_py3 import ManagedDatabaseSecurityAlertPolicy +from ._models_py3 import ManagedDatabaseSecurityAlertPolicyListResult +from ._models_py3 import ManagedDatabaseUpdate +from ._models_py3 import ManagedInstance +from ._models_py3 import ManagedInstanceAdministrator +from ._models_py3 import ManagedInstanceAdministratorListResult +from ._models_py3 import ManagedInstanceAzureADOnlyAuthListResult +from ._models_py3 import ManagedInstanceAzureADOnlyAuthentication +from ._models_py3 import ManagedInstanceEditionCapability +from ._models_py3 import ManagedInstanceEncryptionProtector +from ._models_py3 import ManagedInstanceEncryptionProtectorListResult +from ._models_py3 import ManagedInstanceExternalAdministrator +from ._models_py3 import ManagedInstanceFamilyCapability +from ._models_py3 import ManagedInstanceKey +from ._models_py3 import ManagedInstanceKeyListResult +from ._models_py3 import ManagedInstanceListResult +from ._models_py3 import ManagedInstanceLongTermRetentionBackup +from ._models_py3 import ManagedInstanceLongTermRetentionBackupListResult +from ._models_py3 import ManagedInstanceLongTermRetentionPolicy +from ._models_py3 import ManagedInstanceLongTermRetentionPolicyListResult +from ._models_py3 import ManagedInstanceMaintenanceConfigurationCapability +from ._models_py3 import ManagedInstanceOperation +from ._models_py3 import ManagedInstanceOperationListResult +from ._models_py3 import ManagedInstanceOperationParametersPair +from ._models_py3 import ManagedInstanceOperationSteps +from ._models_py3 import ManagedInstancePairInfo +from ._models_py3 import ManagedInstancePecProperty +from ._models_py3 import ManagedInstancePrivateEndpointConnection +from ._models_py3 import ManagedInstancePrivateEndpointConnectionListResult +from ._models_py3 import ManagedInstancePrivateEndpointConnectionProperties +from ._models_py3 import ManagedInstancePrivateEndpointProperty +from ._models_py3 import ManagedInstancePrivateLink +from ._models_py3 import ManagedInstancePrivateLinkListResult +from ._models_py3 import ManagedInstancePrivateLinkProperties +from ._models_py3 import ManagedInstancePrivateLinkServiceConnectionStateProperty +from ._models_py3 import ManagedInstanceQuery +from ._models_py3 import ManagedInstanceQueryStatistics +from ._models_py3 import ManagedInstanceUpdate +from ._models_py3 import ManagedInstanceVcoresCapability +from ._models_py3 import ManagedInstanceVersionCapability +from ._models_py3 import ManagedInstanceVulnerabilityAssessment +from ._models_py3 import ManagedInstanceVulnerabilityAssessmentListResult +from ._models_py3 import ManagedServerSecurityAlertPolicy +from ._models_py3 import ManagedServerSecurityAlertPolicyListResult +from ._models_py3 import ManagedTransparentDataEncryption +from ._models_py3 import ManagedTransparentDataEncryptionListResult +from ._models_py3 import MaxSizeCapability +from ._models_py3 import MaxSizeRangeCapability +from ._models_py3 import Metric +from ._models_py3 import MetricAvailability +from ._models_py3 import MetricDefinition +from ._models_py3 import MetricDefinitionListResult +from ._models_py3 import MetricListResult +from ._models_py3 import MetricName +from ._models_py3 import MetricValue +from ._models_py3 import MinCapacityCapability +from ._models_py3 import Name +from ._models_py3 import NetworkIsolationSettings +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationImpact +from ._models_py3 import OperationListResult +from ._models_py3 import OutboundFirewallRule +from ._models_py3 import OutboundFirewallRuleListResult +from ._models_py3 import PartnerInfo +from ._models_py3 import PartnerRegionInfo +from ._models_py3 import PerformanceLevelCapability +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateEndpointConnectionRequestStatus +from ._models_py3 import PrivateEndpointProperty +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkResourceProperties +from ._models_py3 import PrivateLinkServiceConnectionStateProperty +from ._models_py3 import ProxyResource +from ._models_py3 import ProxyResourceWithWritableName +from ._models_py3 import QueryMetricInterval +from ._models_py3 import QueryMetricProperties +from ._models_py3 import QueryStatistics +from ._models_py3 import QueryStatisticsProperties +from ._models_py3 import ReadScaleCapability +from ._models_py3 import RecommendedAction +from ._models_py3 import RecommendedActionErrorInfo +from ._models_py3 import RecommendedActionImpactRecord +from ._models_py3 import RecommendedActionImplementationInfo +from ._models_py3 import RecommendedActionMetricInfo +from ._models_py3 import RecommendedActionStateInfo +from ._models_py3 import RecommendedSensitivityLabelUpdate +from ._models_py3 import RecommendedSensitivityLabelUpdateList +from ._models_py3 import RecoverableDatabase +from ._models_py3 import RecoverableDatabaseListResult +from ._models_py3 import RecoverableManagedDatabase +from ._models_py3 import RecoverableManagedDatabaseListResult +from ._models_py3 import ReplicationLink +from ._models_py3 import ReplicationLinkListResult +from ._models_py3 import Resource +from ._models_py3 import ResourceIdentity +from ._models_py3 import ResourceMoveDefinition +from ._models_py3 import ResourceWithWritableName +from ._models_py3 import RestorableDroppedDatabase +from ._models_py3 import RestorableDroppedDatabaseListResult +from ._models_py3 import RestorableDroppedManagedDatabase +from ._models_py3 import RestorableDroppedManagedDatabaseListResult +from ._models_py3 import RestorePoint +from ._models_py3 import RestorePointListResult +from ._models_py3 import SecurityEvent +from ._models_py3 import SecurityEventCollection +from ._models_py3 import SecurityEventSqlInjectionAdditionalProperties +from ._models_py3 import SecurityEventsFilterParameters +from ._models_py3 import SensitivityLabel +from ._models_py3 import SensitivityLabelListResult +from ._models_py3 import SensitivityLabelUpdate +from ._models_py3 import SensitivityLabelUpdateList +from ._models_py3 import Server +from ._models_py3 import ServerAutomaticTuning +from ._models_py3 import ServerAzureADAdministrator +from ._models_py3 import ServerAzureADOnlyAuthentication +from ._models_py3 import ServerBlobAuditingPolicy +from ._models_py3 import ServerBlobAuditingPolicyListResult +from ._models_py3 import ServerCommunicationLink +from ._models_py3 import ServerCommunicationLinkListResult +from ._models_py3 import ServerConnectionPolicy +from ._models_py3 import ServerConnectionPolicyListResult +from ._models_py3 import ServerDevOpsAuditSettingsListResult +from ._models_py3 import ServerDevOpsAuditingSettings +from ._models_py3 import ServerDnsAlias +from ._models_py3 import ServerDnsAliasAcquisition +from ._models_py3 import ServerDnsAliasListResult +from ._models_py3 import ServerExternalAdministrator +from ._models_py3 import ServerInfo +from ._models_py3 import ServerKey +from ._models_py3 import ServerKeyListResult +from ._models_py3 import ServerListResult +from ._models_py3 import ServerOperation +from ._models_py3 import ServerOperationListResult +from ._models_py3 import ServerPrivateEndpointConnection +from ._models_py3 import ServerSecurityAlertPolicy +from ._models_py3 import ServerTrustGroup +from ._models_py3 import ServerTrustGroupListResult +from ._models_py3 import ServerUpdate +from ._models_py3 import ServerUsage +from ._models_py3 import ServerUsageListResult +from ._models_py3 import ServerVersionCapability +from ._models_py3 import ServerVulnerabilityAssessment +from ._models_py3 import ServerVulnerabilityAssessmentListResult +from ._models_py3 import ServiceObjective +from ._models_py3 import ServiceObjectiveCapability +from ._models_py3 import ServiceObjectiveListResult +from ._models_py3 import ServicePrincipal +from ._models_py3 import Sku +from ._models_py3 import SloUsageMetric +from ._models_py3 import SqlAgentConfiguration +from ._models_py3 import StorageCapability +from ._models_py3 import SubscriptionUsage +from ._models_py3 import SubscriptionUsageListResult +from ._models_py3 import SyncAgent +from ._models_py3 import SyncAgentKeyProperties +from ._models_py3 import SyncAgentLinkedDatabase +from ._models_py3 import SyncAgentLinkedDatabaseListResult +from ._models_py3 import SyncAgentListResult +from ._models_py3 import SyncDatabaseIdListResult +from ._models_py3 import SyncDatabaseIdProperties +from ._models_py3 import SyncFullSchemaProperties +from ._models_py3 import SyncFullSchemaPropertiesListResult +from ._models_py3 import SyncFullSchemaTable +from ._models_py3 import SyncFullSchemaTableColumn +from ._models_py3 import SyncGroup +from ._models_py3 import SyncGroupListResult +from ._models_py3 import SyncGroupLogListResult +from ._models_py3 import SyncGroupLogProperties +from ._models_py3 import SyncGroupSchema +from ._models_py3 import SyncGroupSchemaTable +from ._models_py3 import SyncGroupSchemaTableColumn +from ._models_py3 import SyncMember +from ._models_py3 import SyncMemberListResult +from ._models_py3 import SystemData +from ._models_py3 import TdeCertificate +from ._models_py3 import TimeZone +from ._models_py3 import TimeZoneListResult +from ._models_py3 import TopQueries +from ._models_py3 import TopQueriesListResult +from ._models_py3 import TrackedResource +from ._models_py3 import UnlinkParameters +from ._models_py3 import UpdateLongTermRetentionBackupParameters +from ._models_py3 import UpdateManagedInstanceDnsServersOperation +from ._models_py3 import UpsertManagedServerOperationParameters +from ._models_py3 import UpsertManagedServerOperationStep +from ._models_py3 import Usage +from ._models_py3 import UsageListResult +from ._models_py3 import UserIdentity +from ._models_py3 import VirtualCluster +from ._models_py3 import VirtualClusterListResult +from ._models_py3 import VirtualClusterUpdate +from ._models_py3 import VirtualNetworkRule +from ._models_py3 import VirtualNetworkRuleListResult +from ._models_py3 import VulnerabilityAssessmentRecurringScansProperties +from ._models_py3 import VulnerabilityAssessmentScanError +from ._models_py3 import VulnerabilityAssessmentScanRecord +from ._models_py3 import VulnerabilityAssessmentScanRecordListResult +from ._models_py3 import WorkloadClassifier +from ._models_py3 import WorkloadClassifierListResult +from ._models_py3 import WorkloadGroup +from ._models_py3 import WorkloadGroupListResult + from ._sql_management_client_enums import ( AdministratorName, @@ -736,7 +392,6 @@ ElasticPoolLicenseType, ElasticPoolState, EncryptionProtectorName, - Enum60, FailoverGroupReplicationRole, GeoBackupPolicyName, GeoBackupPolicyState, @@ -817,6 +472,7 @@ SyncDirection, SyncGroupLogType, SyncGroupState, + SyncGroupsType, SyncMemberDbType, SyncMemberState, TableTemporalType, @@ -912,6 +568,9 @@ 'FirewallRuleListResult', 'GeoBackupPolicy', 'GeoBackupPolicyListResult', + 'IPv6FirewallRule', + 'IPv6FirewallRuleList', + 'IPv6FirewallRuleListResult', 'ImportExistingDatabaseDefinition', 'ImportExportExtensionsOperationListResult', 'ImportExportExtensionsOperationResult', @@ -1032,8 +691,6 @@ 'OperationDisplay', 'OperationImpact', 'OperationListResult', - 'OperationsHealth', - 'OperationsHealthListResult', 'OutboundFirewallRule', 'OutboundFirewallRuleListResult', 'PartnerInfo', @@ -1215,7 +872,6 @@ 'ElasticPoolLicenseType', 'ElasticPoolState', 'EncryptionProtectorName', - 'Enum60', 'FailoverGroupReplicationRole', 'GeoBackupPolicyName', 'GeoBackupPolicyState', @@ -1296,6 +952,7 @@ 'SyncDirection', 'SyncGroupLogType', 'SyncGroupState', + 'SyncGroupsType', 'SyncMemberDbType', 'SyncMemberState', 'TableTemporalType', diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py deleted file mode 100644 index eb0f3bff19f7c..0000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py +++ /dev/null @@ -1,16177 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class AdministratorListResult(msrest.serialization.Model): - """A list of active directory administrators. - - 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.ServerAzureADAdministrator] - :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': '[ServerAzureADAdministrator]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AdministratorListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Resource(msrest.serialization.Model): - """ARM resource. - - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ProxyResource(Resource): - """ARM proxy resource. - - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class Advisor(ProxyResource): - """Database, Server or Elastic Pool Advisor. - - 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 kind: Resource kind. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar advisor_status: Gets the status of availability of this advisor to customers. Possible - values are 'GA', 'PublicPreview', 'LimitedPublicPreview' and 'PrivatePreview'. Possible values - include: "GA", "PublicPreview", "LimitedPublicPreview", "PrivatePreview". - :vartype advisor_status: str or ~azure.mgmt.sql.models.AdvisorStatus - :param auto_execute_status: Gets the auto-execute status (whether to let the system execute the - recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. Possible values - include: "Enabled", "Disabled", "Default". - :type auto_execute_status: str or ~azure.mgmt.sql.models.AutoExecuteStatus - :ivar auto_execute_status_inherited_from: Gets the resource from which current value of - auto-execute status is inherited. Auto-execute status can be set on (and inherited from) - different levels in the resource hierarchy. Possible values are 'Subscription', 'Server', - 'ElasticPool', 'Database' and 'Default' (when status is not explicitly set on any level). - Possible values include: "Default", "Subscription", "Server", "ElasticPool", "Database". - :vartype auto_execute_status_inherited_from: str or - ~azure.mgmt.sql.models.AutoExecuteStatusInheritedFrom - :ivar recommendations_status: Gets that status of recommendations for this advisor and reason - for not having any recommendations. Possible values include, but are not limited to, 'Ok' - (Recommendations available),LowActivity (not enough workload to analyze), 'DbSeemsTuned' - (Database is doing well), etc. - :vartype recommendations_status: str - :ivar last_checked: Gets the time when the current resource was analyzed for recommendations by - this advisor. - :vartype last_checked: ~datetime.datetime - :ivar recommended_actions: Gets the recommended actions for this advisor. - :vartype recommended_actions: list[~azure.mgmt.sql.models.RecommendedAction] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, - 'advisor_status': {'readonly': True}, - 'auto_execute_status_inherited_from': {'readonly': True}, - 'recommendations_status': {'readonly': True}, - 'last_checked': {'readonly': True}, - 'recommended_actions': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'advisor_status': {'key': 'properties.advisorStatus', 'type': 'str'}, - 'auto_execute_status': {'key': 'properties.autoExecuteStatus', 'type': 'str'}, - 'auto_execute_status_inherited_from': {'key': 'properties.autoExecuteStatusInheritedFrom', 'type': 'str'}, - 'recommendations_status': {'key': 'properties.recommendationsStatus', 'type': 'str'}, - 'last_checked': {'key': 'properties.lastChecked', 'type': 'iso-8601'}, - 'recommended_actions': {'key': 'properties.recommendedActions', 'type': '[RecommendedAction]'}, - } - - def __init__( - self, - **kwargs - ): - super(Advisor, self).__init__(**kwargs) - self.kind = None - self.location = None - self.advisor_status = None - self.auto_execute_status = kwargs.get('auto_execute_status', None) - self.auto_execute_status_inherited_from = None - self.recommendations_status = None - self.last_checked = None - self.recommended_actions = None - - -class AutomaticTuningOptions(msrest.serialization.Model): - """Automatic tuning properties for individual advisors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param desired_state: Automatic tuning option desired state. Possible values include: "Off", - "On", "Default". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired - :ivar actual_state: Automatic tuning option actual state. Possible values include: "Off", "On". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual - :ivar reason_code: Reason code if desired and actual state are different. - :vartype reason_code: int - :ivar reason_desc: Reason description if desired and actual state are different. Possible - values include: "Default", "Disabled", "AutoConfigured", "InheritedFromServer", - "QueryStoreOff", "QueryStoreReadOnly", "NotSupported". - :vartype reason_desc: str or ~azure.mgmt.sql.models.AutomaticTuningDisabledReason - """ - - _validation = { - 'actual_state': {'readonly': True}, - 'reason_code': {'readonly': True}, - 'reason_desc': {'readonly': True}, - } - - _attribute_map = { - 'desired_state': {'key': 'desiredState', 'type': 'str'}, - 'actual_state': {'key': 'actualState', 'type': 'str'}, - 'reason_code': {'key': 'reasonCode', 'type': 'int'}, - 'reason_desc': {'key': 'reasonDesc', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomaticTuningOptions, self).__init__(**kwargs) - self.desired_state = kwargs.get('desired_state', None) - self.actual_state = None - self.reason_code = None - self.reason_desc = None - - -class AutomaticTuningServerOptions(msrest.serialization.Model): - """Automatic tuning properties for individual advisors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param desired_state: Automatic tuning option desired state. Possible values include: "Off", - "On", "Default". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired - :ivar actual_state: Automatic tuning option actual state. Possible values include: "Off", "On". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual - :ivar reason_code: Reason code if desired and actual state are different. - :vartype reason_code: int - :ivar reason_desc: Reason description if desired and actual state are different. Possible - values include: "Default", "Disabled", "AutoConfigured". - :vartype reason_desc: str or ~azure.mgmt.sql.models.AutomaticTuningServerReason - """ - - _validation = { - 'actual_state': {'readonly': True}, - 'reason_code': {'readonly': True}, - 'reason_desc': {'readonly': True}, - } - - _attribute_map = { - 'desired_state': {'key': 'desiredState', 'type': 'str'}, - 'actual_state': {'key': 'actualState', 'type': 'str'}, - 'reason_code': {'key': 'reasonCode', 'type': 'int'}, - 'reason_desc': {'key': 'reasonDesc', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomaticTuningServerOptions, self).__init__(**kwargs) - self.desired_state = kwargs.get('desired_state', None) - self.actual_state = None - self.reason_code = None - self.reason_desc = None - - -class AutoPauseDelayTimeRange(msrest.serialization.Model): - """Supported auto pause delay time range. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar min_value: Minimum value. - :vartype min_value: int - :ivar max_value: Maximum value. - :vartype max_value: int - :ivar step_size: Step value for discrete values between the minimum value and the maximum - value. - :vartype step_size: int - :ivar default: Default value is no value is provided. - :vartype default: int - :ivar unit: Unit of time that delay is expressed in. Possible values include: "Minutes". - :vartype unit: str or ~azure.mgmt.sql.models.PauseDelayTimeUnit - :ivar do_not_pause_value: Value that is used to not pause (infinite delay before pause). - :vartype do_not_pause_value: int - """ - - _validation = { - 'min_value': {'readonly': True}, - 'max_value': {'readonly': True}, - 'step_size': {'readonly': True}, - 'default': {'readonly': True}, - 'unit': {'readonly': True}, - 'do_not_pause_value': {'readonly': True}, - } - - _attribute_map = { - 'min_value': {'key': 'minValue', 'type': 'int'}, - 'max_value': {'key': 'maxValue', 'type': 'int'}, - 'step_size': {'key': 'stepSize', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'do_not_pause_value': {'key': 'doNotPauseValue', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoPauseDelayTimeRange, self).__init__(**kwargs) - self.min_value = None - self.max_value = None - self.step_size = None - self.default = None - self.unit = None - self.do_not_pause_value = None - - -class AzureADOnlyAuthListResult(msrest.serialization.Model): - """A list of active directory only authentications. - - 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.ServerAzureADOnlyAuthentication] - :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': '[ServerAzureADOnlyAuthentication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureADOnlyAuthListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class BackupShortTermRetentionPolicy(ProxyResource): - """A short term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param retention_days: The backup retention period in days. This is how many days Point-in-Time - Restore will be supported. - :type retention_days: int - :param diff_backup_interval_in_hours: The differential backup interval in hours. This is how - many interval hours between each differential backup will be supported. This is only applicable - to live databases but not dropped databases. Possible values include: 12, 24. - :type diff_backup_interval_in_hours: str or ~azure.mgmt.sql.models.DiffBackupIntervalInHours - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'diff_backup_interval_in_hours': {'key': 'properties.diffBackupIntervalInHours', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupShortTermRetentionPolicy, self).__init__(**kwargs) - self.retention_days = kwargs.get('retention_days', None) - self.diff_backup_interval_in_hours = kwargs.get('diff_backup_interval_in_hours', None) - - -class BackupShortTermRetentionPolicyListResult(msrest.serialization.Model): - """A list of short term retention policies. - - 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.BackupShortTermRetentionPolicy] - :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': '[BackupShortTermRetentionPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupShortTermRetentionPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class CheckNameAvailabilityRequest(msrest.serialization.Model): - """A request to check whether the specified name for a resource is available. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. - :type name: str - :ivar type: Has constant value: "Microsoft.Sql/servers". - :vartype type: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - type = "Microsoft.Sql/servers" - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityRequest, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResponse(msrest.serialization.Model): - """The result of a name availability check. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name whose availability was checked. - :vartype name: str - :ivar available: True if the name is available, otherwise false. - :vartype available: bool - :ivar reason: The reason code explaining why the name is unavailable. Will be undefined if the - name is available. Possible values include: "Invalid", "AlreadyExists". - :vartype reason: str or ~azure.mgmt.sql.models.CheckNameAvailabilityReason - :ivar message: A message explaining why the name is unavailable. Will be undefined if the name - is available. - :vartype message: str - """ - - _validation = { - 'name': {'readonly': True}, - 'available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'available': {'key': 'available', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResponse, self).__init__(**kwargs) - self.name = None - self.available = None - self.reason = None - self.message = None - - -class CompleteDatabaseRestoreDefinition(msrest.serialization.Model): - """Contains the information necessary to perform a complete database restore operation. - - All required parameters must be populated in order to send to Azure. - - :param last_backup_name: Required. The last backup name to apply. - :type last_backup_name: str - """ - - _validation = { - 'last_backup_name': {'required': True}, - } - - _attribute_map = { - 'last_backup_name': {'key': 'lastBackupName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CompleteDatabaseRestoreDefinition, self).__init__(**kwargs) - self.last_backup_name = kwargs['last_backup_name'] - - -class CopyLongTermRetentionBackupParameters(msrest.serialization.Model): - """Contains the information necessary to perform long term retention backup copy operation. - - :param target_subscription_id: The subscription that owns the target server. - :type target_subscription_id: str - :param target_resource_group: The resource group that owns the target server. - :type target_resource_group: str - :param target_server_resource_id: The resource Id of the target server that owns the database. - :type target_server_resource_id: str - :param target_server_fully_qualified_domain_name: The fully qualified domain name of the target - server. - :type target_server_fully_qualified_domain_name: str - :param target_database_name: The name of the database owns the copied backup. - :type target_database_name: str - :param target_backup_storage_redundancy: The storage redundancy type of the copied backup. - Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type target_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _attribute_map = { - 'target_subscription_id': {'key': 'properties.targetSubscriptionId', 'type': 'str'}, - 'target_resource_group': {'key': 'properties.targetResourceGroup', 'type': 'str'}, - 'target_server_resource_id': {'key': 'properties.targetServerResourceId', 'type': 'str'}, - 'target_server_fully_qualified_domain_name': {'key': 'properties.targetServerFullyQualifiedDomainName', 'type': 'str'}, - 'target_database_name': {'key': 'properties.targetDatabaseName', 'type': 'str'}, - 'target_backup_storage_redundancy': {'key': 'properties.targetBackupStorageRedundancy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CopyLongTermRetentionBackupParameters, self).__init__(**kwargs) - self.target_subscription_id = kwargs.get('target_subscription_id', None) - self.target_resource_group = kwargs.get('target_resource_group', None) - self.target_server_resource_id = kwargs.get('target_server_resource_id', None) - self.target_server_fully_qualified_domain_name = kwargs.get('target_server_fully_qualified_domain_name', None) - self.target_database_name = kwargs.get('target_database_name', None) - self.target_backup_storage_redundancy = kwargs.get('target_backup_storage_redundancy', None) - - -class CreateDatabaseRestorePointDefinition(msrest.serialization.Model): - """Contains the information necessary to perform a create database restore point operation. - - All required parameters must be populated in order to send to Azure. - - :param restore_point_label: Required. The restore point label to apply. - :type restore_point_label: str - """ - - _validation = { - 'restore_point_label': {'required': True}, - } - - _attribute_map = { - 'restore_point_label': {'key': 'restorePointLabel', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateDatabaseRestorePointDefinition, self).__init__(**kwargs) - self.restore_point_label = kwargs['restore_point_label'] - - -class TrackedResource(Resource): - """ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class Database(TrackedResource): - """A database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The database SKU. - - The list of SKUs may vary by region and support offer. To determine the SKUs (including the - SKU name, tier/edition, family, and capacity) that are available to your subscription in an - Azure region, use the ``Capabilities_ListByLocation`` REST API or one of the following - commands: - - .. code-block:: azurecli - - az sql db list-editions -l -o table - ` - - .. code-block:: powershell - - Get-AzSqlServerServiceObjective -Location - `. - :type sku: ~azure.mgmt.sql.models.Sku - :ivar kind: Kind of database. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar managed_by: Resource that manages the database. - :vartype managed_by: str - :param identity: The Azure Active Directory identity of the database. - :type identity: ~azure.mgmt.sql.models.DatabaseIdentity - :param create_mode: Specifies the mode of database creation. - - Default: regular database creation. - - Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified - as the resource ID of the source database. - - Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId - must be specified as the resource ID of the existing primary database. - - PointInTimeRestore: Creates a database by restoring a point in time backup of an existing - database. sourceDatabaseId must be specified as the resource ID of the existing database, and - restorePointInTime must be specified. - - Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be - specified as the recoverable database resource ID to restore. - - Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must - be specified. If sourceDatabaseId is the database's original resource ID, then - sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable - dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may - also be specified to restore from an earlier point in time. - - RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention - vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource - ID. - - Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse - edition. Possible values include: "Default", "Copy", "Secondary", "PointInTimeRestore", - "Restore", "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", - "RestoreLongTermRetentionBackup", "OnlineSecondary". - :type create_mode: str or ~azure.mgmt.sql.models.CreateMode - :param collation: The collation of the database. - :type collation: str - :param max_size_bytes: The max size of the database expressed in bytes. - :type max_size_bytes: long - :param sample_name: The name of the sample schema to apply when creating this database. - Possible values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". - :type sample_name: str or ~azure.mgmt.sql.models.SampleName - :param elastic_pool_id: The resource identifier of the elastic pool containing this database. - :type elastic_pool_id: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str - :ivar status: The status of the database. Possible values include: "Online", "Restoring", - "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", - "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", - "Resuming", "Scaling", "OfflineChangingDwPerformanceTiers", "OnlineChangingDwPerformanceTiers", - "Disabled", "Stopping", "Stopped", "Starting". - :vartype status: str or ~azure.mgmt.sql.models.DatabaseStatus - :ivar database_id: The ID of the database. - :vartype database_id: str - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar current_service_objective_name: The current service level objective name of the database. - :vartype current_service_objective_name: str - :ivar requested_service_objective_name: The requested service level objective name of the - database. - :vartype requested_service_objective_name: str - :ivar default_secondary_location: The default secondary region for this database. - :vartype default_secondary_location: str - :ivar failover_group_id: Failover Group resource identifier that this database belongs to. - :vartype failover_group_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param source_database_deletion_date: Specifies the time that the database was deleted. - :type source_database_deletion_date: ~datetime.datetime - :param recovery_services_recovery_point_id: The resource identifier of the recovery point - associated with create operation of this database. - :type recovery_services_recovery_point_id: str - :param long_term_retention_backup_resource_id: The resource identifier of the long term - retention backup associated with create operation of this database. - :type long_term_retention_backup_resource_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :type recoverable_database_id: str - :param restorable_dropped_database_id: The resource identifier of the restorable dropped - database associated with create operation of this database. - :type restorable_dropped_database_id: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: - "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param zone_redundant: Whether or not this database is zone redundant, which means the replicas - of this database will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this database. ``LicenseIncluded`` if you - need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid - Benefit. Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType - :ivar max_log_size_bytes: The max log size for this database. - :vartype max_log_size_bytes: long - :ivar earliest_restore_date: This records the earliest start date and time that restore is - available for this database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - :param read_scale: The state of read-only routing. If enabled, connections that have - application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Possible values include: "Enabled", "Disabled". - :type read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :param high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. - :type high_availability_replica_count: int - :param secondary_type: The secondary type of the database if it is a secondary. Valid values - are Geo and Named. Possible values include: "Geo", "Named". - :type secondary_type: str or ~azure.mgmt.sql.models.SecondaryType - :ivar current_sku: The name and tier of the SKU. - :vartype current_sku: ~azure.mgmt.sql.models.Sku - :param auto_pause_delay: Time in minutes after which database is automatically paused. A value - of -1 means that automatic pause is disabled. - :type auto_pause_delay: int - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param min_capacity: Minimal capacity that database will always have allocated, if not paused. - :type min_capacity: float - :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 - format). Null if the database is ready. - :vartype paused_date: ~datetime.datetime - :ivar resumed_date: The date when database was resumed by user action or database login - (ISO8601 format). Null if the database is paused. - :vartype resumed_date: ~datetime.datetime - :param maintenance_configuration_id: Maintenance configuration id assigned to the database. - This configuration defines the period when the maintenance updates will occur. - :type maintenance_configuration_id: str - :param is_ledger_on: Whether or not this database is a ledger database, which means all tables - in the database are ledger tables. Note: the value of this property cannot be changed after the - database has been created. - :type is_ledger_on: bool - :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. - :vartype is_infra_encryption_enabled: bool - :param federated_client_id: The Client id used for cross tenant per database CMK scenario. - :type federated_client_id: str - :param primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for - per database CMK - for internal use only. - :type primary_delegated_identity_client_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'managed_by': {'readonly': True}, - 'status': {'readonly': True}, - 'database_id': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'current_service_objective_name': {'readonly': True}, - 'requested_service_objective_name': {'readonly': True}, - 'default_secondary_location': {'readonly': True}, - 'failover_group_id': {'readonly': True}, - 'max_log_size_bytes': {'readonly': True}, - 'earliest_restore_date': {'readonly': True}, - 'current_sku': {'readonly': True}, - 'current_backup_storage_redundancy': {'readonly': True}, - 'paused_date': {'readonly': True}, - 'resumed_date': {'readonly': True}, - 'is_infra_encryption_enabled': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'DatabaseIdentity'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'long'}, - 'sample_name': {'key': 'properties.sampleName', 'type': 'str'}, - 'elastic_pool_id': {'key': 'properties.elasticPoolId', 'type': 'str'}, - 'source_database_id': {'key': 'properties.sourceDatabaseId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'database_id': {'key': 'properties.databaseId', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'current_service_objective_name': {'key': 'properties.currentServiceObjectiveName', 'type': 'str'}, - 'requested_service_objective_name': {'key': 'properties.requestedServiceObjectiveName', 'type': 'str'}, - 'default_secondary_location': {'key': 'properties.defaultSecondaryLocation', 'type': 'str'}, - 'failover_group_id': {'key': 'properties.failoverGroupId', 'type': 'str'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'source_database_deletion_date': {'key': 'properties.sourceDatabaseDeletionDate', 'type': 'iso-8601'}, - 'recovery_services_recovery_point_id': {'key': 'properties.recoveryServicesRecoveryPointId', 'type': 'str'}, - 'long_term_retention_backup_resource_id': {'key': 'properties.longTermRetentionBackupResourceId', 'type': 'str'}, - 'recoverable_database_id': {'key': 'properties.recoverableDatabaseId', 'type': 'str'}, - 'restorable_dropped_database_id': {'key': 'properties.restorableDroppedDatabaseId', 'type': 'str'}, - 'catalog_collation': {'key': 'properties.catalogCollation', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'license_type': {'key': 'properties.licenseType', 'type': 'str'}, - 'max_log_size_bytes': {'key': 'properties.maxLogSizeBytes', 'type': 'long'}, - 'earliest_restore_date': {'key': 'properties.earliestRestoreDate', 'type': 'iso-8601'}, - 'read_scale': {'key': 'properties.readScale', 'type': 'str'}, - 'high_availability_replica_count': {'key': 'properties.highAvailabilityReplicaCount', 'type': 'int'}, - 'secondary_type': {'key': 'properties.secondaryType', 'type': 'str'}, - 'current_sku': {'key': 'properties.currentSku', 'type': 'Sku'}, - 'auto_pause_delay': {'key': 'properties.autoPauseDelay', 'type': 'int'}, - 'current_backup_storage_redundancy': {'key': 'properties.currentBackupStorageRedundancy', 'type': 'str'}, - 'requested_backup_storage_redundancy': {'key': 'properties.requestedBackupStorageRedundancy', 'type': 'str'}, - 'min_capacity': {'key': 'properties.minCapacity', 'type': 'float'}, - 'paused_date': {'key': 'properties.pausedDate', 'type': 'iso-8601'}, - 'resumed_date': {'key': 'properties.resumedDate', 'type': 'iso-8601'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - 'is_ledger_on': {'key': 'properties.isLedgerOn', 'type': 'bool'}, - 'is_infra_encryption_enabled': {'key': 'properties.isInfraEncryptionEnabled', 'type': 'bool'}, - 'federated_client_id': {'key': 'properties.federatedClientId', 'type': 'str'}, - 'primary_delegated_identity_client_id': {'key': 'properties.primaryDelegatedIdentityClientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Database, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.kind = None - self.managed_by = None - self.identity = kwargs.get('identity', None) - self.create_mode = kwargs.get('create_mode', None) - self.collation = kwargs.get('collation', None) - self.max_size_bytes = kwargs.get('max_size_bytes', None) - self.sample_name = kwargs.get('sample_name', None) - self.elastic_pool_id = kwargs.get('elastic_pool_id', None) - self.source_database_id = kwargs.get('source_database_id', None) - self.status = None - self.database_id = None - self.creation_date = None - self.current_service_objective_name = None - self.requested_service_objective_name = None - self.default_secondary_location = None - self.failover_group_id = None - self.restore_point_in_time = kwargs.get('restore_point_in_time', None) - self.source_database_deletion_date = kwargs.get('source_database_deletion_date', None) - self.recovery_services_recovery_point_id = kwargs.get('recovery_services_recovery_point_id', None) - self.long_term_retention_backup_resource_id = kwargs.get('long_term_retention_backup_resource_id', None) - self.recoverable_database_id = kwargs.get('recoverable_database_id', None) - self.restorable_dropped_database_id = kwargs.get('restorable_dropped_database_id', None) - self.catalog_collation = kwargs.get('catalog_collation', None) - self.zone_redundant = kwargs.get('zone_redundant', None) - self.license_type = kwargs.get('license_type', None) - self.max_log_size_bytes = None - self.earliest_restore_date = None - self.read_scale = kwargs.get('read_scale', None) - self.high_availability_replica_count = kwargs.get('high_availability_replica_count', None) - self.secondary_type = kwargs.get('secondary_type', None) - self.current_sku = None - self.auto_pause_delay = kwargs.get('auto_pause_delay', None) - self.current_backup_storage_redundancy = None - self.requested_backup_storage_redundancy = kwargs.get('requested_backup_storage_redundancy', None) - self.min_capacity = kwargs.get('min_capacity', None) - self.paused_date = None - self.resumed_date = None - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - self.is_ledger_on = kwargs.get('is_ledger_on', None) - self.is_infra_encryption_enabled = None - self.federated_client_id = kwargs.get('federated_client_id', None) - self.primary_delegated_identity_client_id = kwargs.get('primary_delegated_identity_client_id', None) - - -class DatabaseAutomaticTuning(ProxyResource): - """Database-level Automatic Tuning. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param desired_state: Automatic tuning desired state. Possible values include: "Inherit", - "Custom", "Auto", "Unspecified". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode - :ivar actual_state: Automatic tuning actual state. Possible values include: "Inherit", - "Custom", "Auto", "Unspecified". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode - :param options: Automatic tuning options definition. - :type options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'actual_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'desired_state': {'key': 'properties.desiredState', 'type': 'str'}, - 'actual_state': {'key': 'properties.actualState', 'type': 'str'}, - 'options': {'key': 'properties.options', 'type': '{AutomaticTuningOptions}'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseAutomaticTuning, self).__init__(**kwargs) - self.desired_state = kwargs.get('desired_state', None) - self.actual_state = None - self.options = kwargs.get('options', None) - - -class DatabaseBlobAuditingPolicy(ProxyResource): - """A database blob auditing policy. - - 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 kind: Resource kind. - :vartype kind: str - :param retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'queue_delay_ms': {'key': 'properties.queueDelayMs', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseBlobAuditingPolicy, self).__init__(**kwargs) - self.kind = None - self.retention_days = kwargs.get('retention_days', None) - self.audit_actions_and_groups = kwargs.get('audit_actions_and_groups', None) - self.is_storage_secondary_key_in_use = kwargs.get('is_storage_secondary_key_in_use', None) - self.is_azure_monitor_target_enabled = kwargs.get('is_azure_monitor_target_enabled', None) - self.queue_delay_ms = kwargs.get('queue_delay_ms', None) - self.state = kwargs.get('state', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.storage_account_subscription_id = kwargs.get('storage_account_subscription_id', None) - - -class DatabaseBlobAuditingPolicyListResult(msrest.serialization.Model): - """A list of database auditing 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.DatabaseBlobAuditingPolicy] - :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': '[DatabaseBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseBlobAuditingPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseColumn(ProxyResource): - """A database column resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param column_type: The column data type. Possible values include: "image", "text", - "uniqueidentifier", "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", - "int", "smalldatetime", "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", - "decimal", "numeric", "smallmoney", "bigint", "hierarchyid", "geometry", "geography", - "varbinary", "varchar", "binary", "char", "timestamp", "nvarchar", "nchar", "xml", "sysname". - :type column_type: str or ~azure.mgmt.sql.models.ColumnDataType - :param temporal_type: The table temporal type. Possible values include: "NonTemporalTable", - "HistoryTable", "SystemVersionedTemporalTable". - :type temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :param memory_optimized: Whether or not the column belongs to a memory optimized table. - :type memory_optimized: bool - :param is_computed: Whether or not the column is computed. - :type is_computed: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'column_type': {'key': 'properties.columnType', 'type': 'str'}, - 'temporal_type': {'key': 'properties.temporalType', 'type': 'str'}, - 'memory_optimized': {'key': 'properties.memoryOptimized', 'type': 'bool'}, - 'is_computed': {'key': 'properties.isComputed', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseColumn, self).__init__(**kwargs) - self.column_type = kwargs.get('column_type', None) - self.temporal_type = kwargs.get('temporal_type', None) - self.memory_optimized = kwargs.get('memory_optimized', None) - self.is_computed = kwargs.get('is_computed', None) - - -class DatabaseColumnListResult(msrest.serialization.Model): - """A list of database columns. - - 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.DatabaseColumn] - :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': '[DatabaseColumn]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseColumnListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseExtensions(ProxyResource): - """An export managed database operation result resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param operation_mode: Operation Mode. Possible values include: "PolybaseImport". - :type operation_mode: str or ~azure.mgmt.sql.models.OperationMode - :param storage_key_type: Storage key type. Possible values include: "SharedAccessKey", - "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Storage key. - :type storage_key: str - :param storage_uri: Storage Uri. - :type storage_uri: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'operation_mode': {'key': 'properties.operationMode', 'type': 'str'}, - 'storage_key_type': {'key': 'properties.storageKeyType', 'type': 'str'}, - 'storage_key': {'key': 'properties.storageKey', 'type': 'str'}, - 'storage_uri': {'key': 'properties.storageUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseExtensions, self).__init__(**kwargs) - self.operation_mode = kwargs.get('operation_mode', None) - self.storage_key_type = kwargs.get('storage_key_type', None) - self.storage_key = kwargs.get('storage_key', None) - self.storage_uri = kwargs.get('storage_uri', None) - - -class DatabaseIdentity(msrest.serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param type: The identity type. Possible values include: "None", "UserAssigned". - :type type: str or ~azure.mgmt.sql.models.DatabaseIdentityType - :ivar tenant_id: The Azure Active Directory tenant id. - :vartype tenant_id: str - :param user_assigned_identities: The resource ids of the user assigned identities to use. - :type user_assigned_identities: dict[str, ~azure.mgmt.sql.models.DatabaseUserIdentity] - :param delegated_resources: Resources delegated to the database - Internal Use Only. - :type delegated_resources: dict[str, ~azure.mgmt.sql.models.Delegation] - """ - - _validation = { - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{DatabaseUserIdentity}'}, - 'delegated_resources': {'key': 'delegatedResources', 'type': '{Delegation}'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseIdentity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.tenant_id = None - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - self.delegated_resources = kwargs.get('delegated_resources', None) - - -class DatabaseListResult(msrest.serialization.Model): - """A list of databases. - - 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.Database] - :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': '[Database]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseOperation(ProxyResource): - """A database operation. - - 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 database_name: The name of the database the operation is being performed on. - :vartype database_name: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar server_name: The name of the server. - :vartype server_name: str - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Possible values include: "Pending", "InProgress", - "Succeeded", "Failed", "CancelInProgress", "Cancelled". - :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'database_name': {'readonly': True}, - 'operation': {'readonly': True}, - 'operation_friendly_name': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'server_name': {'readonly': True}, - 'start_time': {'readonly': True}, - 'state': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_description': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'is_user_error': {'readonly': True}, - 'estimated_completion_time': {'readonly': True}, - 'description': {'readonly': True}, - 'is_cancellable': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'operation_friendly_name': {'key': 'properties.operationFriendlyName', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, - 'error_description': {'key': 'properties.errorDescription', 'type': 'str'}, - 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, - 'is_user_error': {'key': 'properties.isUserError', 'type': 'bool'}, - 'estimated_completion_time': {'key': 'properties.estimatedCompletionTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_cancellable': {'key': 'properties.isCancellable', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseOperation, self).__init__(**kwargs) - self.database_name = None - self.operation = None - self.operation_friendly_name = None - self.percent_complete = None - self.server_name = None - self.start_time = None - self.state = None - self.error_code = None - self.error_description = None - self.error_severity = None - self.is_user_error = None - self.estimated_completion_time = None - self.description = None - self.is_cancellable = None - - -class DatabaseOperationListResult(msrest.serialization.Model): - """The response to a list database operations request. - - 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.DatabaseOperation] - :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': '[DatabaseOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseOperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseSchema(ProxyResource): - """A database schema resource. - - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseSchema, self).__init__(**kwargs) - - -class DatabaseSchemaListResult(msrest.serialization.Model): - """A list of database schemas. - - 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.DatabaseSchema] - :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': '[DatabaseSchema]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseSchemaListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseSecurityAlertListResult(msrest.serialization.Model): - """A list of the database's security alert policies. - - 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.DatabaseSecurityAlertPolicy] - :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': '[DatabaseSecurityAlertPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseSecurityAlertListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseSecurityAlertPolicy(ProxyResource): - """A database security alert policy. - - 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 SecurityAlertPolicyResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Possible values include: "Enabled", - "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int - :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'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseSecurityAlertPolicy, self).__init__(**kwargs) - self.system_data = None - self.state = kwargs.get('state', None) - self.disabled_alerts = kwargs.get('disabled_alerts', None) - self.email_addresses = kwargs.get('email_addresses', None) - self.email_account_admins = kwargs.get('email_account_admins', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.retention_days = kwargs.get('retention_days', None) - self.creation_time = None - - -class DatabaseTable(ProxyResource): - """A database table resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param temporal_type: The table temporal type. Possible values include: "NonTemporalTable", - "HistoryTable", "SystemVersionedTemporalTable". - :type temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :param memory_optimized: Whether or not the table is memory optimized. - :type memory_optimized: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'temporal_type': {'key': 'properties.temporalType', 'type': 'str'}, - 'memory_optimized': {'key': 'properties.memoryOptimized', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseTable, self).__init__(**kwargs) - self.temporal_type = kwargs.get('temporal_type', None) - self.memory_optimized = kwargs.get('memory_optimized', None) - - -class DatabaseTableListResult(msrest.serialization.Model): - """A list of database tables. - - 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.DatabaseTable] - :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': '[DatabaseTable]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseTableListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseUpdate(msrest.serialization.Model): - """A database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param identity: Database identity. - :type identity: ~azure.mgmt.sql.models.DatabaseIdentity - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param create_mode: Specifies the mode of database creation. - - Default: regular database creation. - - Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified - as the resource ID of the source database. - - Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId - must be specified as the resource ID of the existing primary database. - - PointInTimeRestore: Creates a database by restoring a point in time backup of an existing - database. sourceDatabaseId must be specified as the resource ID of the existing database, and - restorePointInTime must be specified. - - Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be - specified as the recoverable database resource ID to restore. - - Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must - be specified. If sourceDatabaseId is the database's original resource ID, then - sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable - dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may - also be specified to restore from an earlier point in time. - - RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention - vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource - ID. - - Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse - edition. Possible values include: "Default", "Copy", "Secondary", "PointInTimeRestore", - "Restore", "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", - "RestoreLongTermRetentionBackup", "OnlineSecondary". - :type create_mode: str or ~azure.mgmt.sql.models.CreateMode - :param collation: The collation of the database. - :type collation: str - :param max_size_bytes: The max size of the database expressed in bytes. - :type max_size_bytes: long - :param sample_name: The name of the sample schema to apply when creating this database. - Possible values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". - :type sample_name: str or ~azure.mgmt.sql.models.SampleName - :param elastic_pool_id: The resource identifier of the elastic pool containing this database. - :type elastic_pool_id: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str - :ivar status: The status of the database. Possible values include: "Online", "Restoring", - "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", - "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", - "Resuming", "Scaling", "OfflineChangingDwPerformanceTiers", "OnlineChangingDwPerformanceTiers", - "Disabled", "Stopping", "Stopped", "Starting". - :vartype status: str or ~azure.mgmt.sql.models.DatabaseStatus - :ivar database_id: The ID of the database. - :vartype database_id: str - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar current_service_objective_name: The current service level objective name of the database. - :vartype current_service_objective_name: str - :ivar requested_service_objective_name: The requested service level objective name of the - database. - :vartype requested_service_objective_name: str - :ivar default_secondary_location: The default secondary region for this database. - :vartype default_secondary_location: str - :ivar failover_group_id: Failover Group resource identifier that this database belongs to. - :vartype failover_group_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param source_database_deletion_date: Specifies the time that the database was deleted. - :type source_database_deletion_date: ~datetime.datetime - :param recovery_services_recovery_point_id: The resource identifier of the recovery point - associated with create operation of this database. - :type recovery_services_recovery_point_id: str - :param long_term_retention_backup_resource_id: The resource identifier of the long term - retention backup associated with create operation of this database. - :type long_term_retention_backup_resource_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :type recoverable_database_id: str - :param restorable_dropped_database_id: The resource identifier of the restorable dropped - database associated with create operation of this database. - :type restorable_dropped_database_id: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: - "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param zone_redundant: Whether or not this database is zone redundant, which means the replicas - of this database will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this database. ``LicenseIncluded`` if you - need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid - Benefit. Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType - :ivar max_log_size_bytes: The max log size for this database. - :vartype max_log_size_bytes: long - :ivar earliest_restore_date: This records the earliest start date and time that restore is - available for this database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - :param read_scale: The state of read-only routing. If enabled, connections that have - application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Possible values include: "Enabled", "Disabled". - :type read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :param high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. - :type high_availability_replica_count: int - :param secondary_type: The secondary type of the database if it is a secondary. Valid values - are Geo and Named. Possible values include: "Geo", "Named". - :type secondary_type: str or ~azure.mgmt.sql.models.SecondaryType - :ivar current_sku: The name and tier of the SKU. - :vartype current_sku: ~azure.mgmt.sql.models.Sku - :param auto_pause_delay: Time in minutes after which database is automatically paused. A value - of -1 means that automatic pause is disabled. - :type auto_pause_delay: int - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param min_capacity: Minimal capacity that database will always have allocated, if not paused. - :type min_capacity: float - :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 - format). Null if the database is ready. - :vartype paused_date: ~datetime.datetime - :ivar resumed_date: The date when database was resumed by user action or database login - (ISO8601 format). Null if the database is paused. - :vartype resumed_date: ~datetime.datetime - :param maintenance_configuration_id: Maintenance configuration id assigned to the database. - This configuration defines the period when the maintenance updates will occur. - :type maintenance_configuration_id: str - :param is_ledger_on: Whether or not this database is a ledger database, which means all tables - in the database are ledger tables. Note: the value of this property cannot be changed after the - database has been created. - :type is_ledger_on: bool - :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. - :vartype is_infra_encryption_enabled: bool - :param federated_client_id: The Client id used for cross tenant per database CMK scenario. - :type federated_client_id: str - :param primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for - per database CMK - for internal use only. - :type primary_delegated_identity_client_id: str - """ - - _validation = { - 'status': {'readonly': True}, - 'database_id': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'current_service_objective_name': {'readonly': True}, - 'requested_service_objective_name': {'readonly': True}, - 'default_secondary_location': {'readonly': True}, - 'failover_group_id': {'readonly': True}, - 'max_log_size_bytes': {'readonly': True}, - 'earliest_restore_date': {'readonly': True}, - 'current_sku': {'readonly': True}, - 'current_backup_storage_redundancy': {'readonly': True}, - 'paused_date': {'readonly': True}, - 'resumed_date': {'readonly': True}, - 'is_infra_encryption_enabled': {'readonly': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'DatabaseIdentity'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'long'}, - 'sample_name': {'key': 'properties.sampleName', 'type': 'str'}, - 'elastic_pool_id': {'key': 'properties.elasticPoolId', 'type': 'str'}, - 'source_database_id': {'key': 'properties.sourceDatabaseId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'database_id': {'key': 'properties.databaseId', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'current_service_objective_name': {'key': 'properties.currentServiceObjectiveName', 'type': 'str'}, - 'requested_service_objective_name': {'key': 'properties.requestedServiceObjectiveName', 'type': 'str'}, - 'default_secondary_location': {'key': 'properties.defaultSecondaryLocation', 'type': 'str'}, - 'failover_group_id': {'key': 'properties.failoverGroupId', 'type': 'str'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'source_database_deletion_date': {'key': 'properties.sourceDatabaseDeletionDate', 'type': 'iso-8601'}, - 'recovery_services_recovery_point_id': {'key': 'properties.recoveryServicesRecoveryPointId', 'type': 'str'}, - 'long_term_retention_backup_resource_id': {'key': 'properties.longTermRetentionBackupResourceId', 'type': 'str'}, - 'recoverable_database_id': {'key': 'properties.recoverableDatabaseId', 'type': 'str'}, - 'restorable_dropped_database_id': {'key': 'properties.restorableDroppedDatabaseId', 'type': 'str'}, - 'catalog_collation': {'key': 'properties.catalogCollation', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'license_type': {'key': 'properties.licenseType', 'type': 'str'}, - 'max_log_size_bytes': {'key': 'properties.maxLogSizeBytes', 'type': 'long'}, - 'earliest_restore_date': {'key': 'properties.earliestRestoreDate', 'type': 'iso-8601'}, - 'read_scale': {'key': 'properties.readScale', 'type': 'str'}, - 'high_availability_replica_count': {'key': 'properties.highAvailabilityReplicaCount', 'type': 'int'}, - 'secondary_type': {'key': 'properties.secondaryType', 'type': 'str'}, - 'current_sku': {'key': 'properties.currentSku', 'type': 'Sku'}, - 'auto_pause_delay': {'key': 'properties.autoPauseDelay', 'type': 'int'}, - 'current_backup_storage_redundancy': {'key': 'properties.currentBackupStorageRedundancy', 'type': 'str'}, - 'requested_backup_storage_redundancy': {'key': 'properties.requestedBackupStorageRedundancy', 'type': 'str'}, - 'min_capacity': {'key': 'properties.minCapacity', 'type': 'float'}, - 'paused_date': {'key': 'properties.pausedDate', 'type': 'iso-8601'}, - 'resumed_date': {'key': 'properties.resumedDate', 'type': 'iso-8601'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - 'is_ledger_on': {'key': 'properties.isLedgerOn', 'type': 'bool'}, - 'is_infra_encryption_enabled': {'key': 'properties.isInfraEncryptionEnabled', 'type': 'bool'}, - 'federated_client_id': {'key': 'properties.federatedClientId', 'type': 'str'}, - 'primary_delegated_identity_client_id': {'key': 'properties.primaryDelegatedIdentityClientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseUpdate, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.tags = kwargs.get('tags', None) - self.create_mode = kwargs.get('create_mode', None) - self.collation = kwargs.get('collation', None) - self.max_size_bytes = kwargs.get('max_size_bytes', None) - self.sample_name = kwargs.get('sample_name', None) - self.elastic_pool_id = kwargs.get('elastic_pool_id', None) - self.source_database_id = kwargs.get('source_database_id', None) - self.status = None - self.database_id = None - self.creation_date = None - self.current_service_objective_name = None - self.requested_service_objective_name = None - self.default_secondary_location = None - self.failover_group_id = None - self.restore_point_in_time = kwargs.get('restore_point_in_time', None) - self.source_database_deletion_date = kwargs.get('source_database_deletion_date', None) - self.recovery_services_recovery_point_id = kwargs.get('recovery_services_recovery_point_id', None) - self.long_term_retention_backup_resource_id = kwargs.get('long_term_retention_backup_resource_id', None) - self.recoverable_database_id = kwargs.get('recoverable_database_id', None) - self.restorable_dropped_database_id = kwargs.get('restorable_dropped_database_id', None) - self.catalog_collation = kwargs.get('catalog_collation', None) - self.zone_redundant = kwargs.get('zone_redundant', None) - self.license_type = kwargs.get('license_type', None) - self.max_log_size_bytes = None - self.earliest_restore_date = None - self.read_scale = kwargs.get('read_scale', None) - self.high_availability_replica_count = kwargs.get('high_availability_replica_count', None) - self.secondary_type = kwargs.get('secondary_type', None) - self.current_sku = None - self.auto_pause_delay = kwargs.get('auto_pause_delay', None) - self.current_backup_storage_redundancy = None - self.requested_backup_storage_redundancy = kwargs.get('requested_backup_storage_redundancy', None) - self.min_capacity = kwargs.get('min_capacity', None) - self.paused_date = None - self.resumed_date = None - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - self.is_ledger_on = kwargs.get('is_ledger_on', None) - self.is_infra_encryption_enabled = None - self.federated_client_id = kwargs.get('federated_client_id', None) - self.primary_delegated_identity_client_id = kwargs.get('primary_delegated_identity_client_id', None) - - -class DatabaseUsage(ProxyResource): - """Usage metric of a database. - - 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 display_name: User-readable name of the metric. - :vartype display_name: str - :ivar current_value: Current value of the metric. - :vartype current_value: float - :ivar limit: Boundary value of the metric. - :vartype limit: float - :ivar unit: Unit of the metric. - :vartype unit: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'current_value': {'key': 'properties.currentValue', 'type': 'float'}, - 'limit': {'key': 'properties.limit', 'type': 'float'}, - 'unit': {'key': 'properties.unit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseUsage, self).__init__(**kwargs) - self.display_name = None - self.current_value = None - self.limit = None - self.unit = None - - -class DatabaseUsageListResult(msrest.serialization.Model): - """A list of database usage metrics. - - 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.DatabaseUsage] - :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': '[DatabaseUsage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseUsageListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseUserIdentity(msrest.serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The Azure Active Directory principal id. - :vartype principal_id: str - :ivar client_id: The Azure Active Directory client id. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseUserIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class DatabaseVulnerabilityAssessment(ProxyResource): - """A database vulnerability assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). It is required if server level - vulnerability assessment policy doesn't set. - :type storage_container_path: str - :param storage_container_sas_key: A shared access signature (SAS Key) that has write access to - the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' - isn't specified, StorageContainerSasKey is required. - :type storage_container_sas_key: str - :param storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. - :type storage_account_access_key: str - :param recurring_scans: The recurring scans settings. - :type recurring_scans: ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_container_path': {'key': 'properties.storageContainerPath', 'type': 'str'}, - 'storage_container_sas_key': {'key': 'properties.storageContainerSasKey', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'recurring_scans': {'key': 'properties.recurringScans', 'type': 'VulnerabilityAssessmentRecurringScansProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseVulnerabilityAssessment, self).__init__(**kwargs) - self.storage_container_path = kwargs.get('storage_container_path', None) - self.storage_container_sas_key = kwargs.get('storage_container_sas_key', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.recurring_scans = kwargs.get('recurring_scans', None) - - -class DatabaseVulnerabilityAssessmentListResult(msrest.serialization.Model): - """A list of the database's vulnerability assessments. - - 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.DatabaseVulnerabilityAssessment] - :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': '[DatabaseVulnerabilityAssessment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseVulnerabilityAssessmentListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DatabaseVulnerabilityAssessmentRuleBaseline(ProxyResource): - """A database vulnerability assessment rule baseline. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param baseline_results: The rule baseline result. - :type baseline_results: - list[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'baseline_results': {'key': 'properties.baselineResults', 'type': '[DatabaseVulnerabilityAssessmentRuleBaselineItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseVulnerabilityAssessmentRuleBaseline, self).__init__(**kwargs) - self.baseline_results = kwargs.get('baseline_results', None) - - -class DatabaseVulnerabilityAssessmentRuleBaselineItem(msrest.serialization.Model): - """Properties for an Azure SQL Database Vulnerability Assessment rule baseline's result. - - All required parameters must be populated in order to send to Azure. - - :param result: Required. The rule baseline result. - :type result: list[str] - """ - - _validation = { - 'result': {'required': True}, - } - - _attribute_map = { - 'result': {'key': 'result', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseVulnerabilityAssessmentRuleBaselineItem, self).__init__(**kwargs) - self.result = kwargs['result'] - - -class DatabaseVulnerabilityAssessmentScansExport(ProxyResource): - """A database Vulnerability Assessment scan export resource. - - 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 exported_report_location: Location of the exported report (e.g. - https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx). - :vartype exported_report_location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'exported_report_location': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'exported_report_location': {'key': 'properties.exportedReportLocation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatabaseVulnerabilityAssessmentScansExport, self).__init__(**kwargs) - self.exported_report_location = None - - -class DataMaskingPolicy(ProxyResource): - """Represents a database data masking policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: The location of the data masking policy. - :vartype location: str - :ivar kind: The kind of data masking policy. Metadata, used for Azure portal. - :vartype kind: str - :param data_masking_state: The state of the data masking policy. Possible values include: - "Disabled", "Enabled". - :type data_masking_state: str or ~azure.mgmt.sql.models.DataMaskingState - :param exempt_principals: The list of the exempt principals. Specifies the semicolon-separated - list of database users for which the data masking policy does not apply. The specified users - receive data results without masking for all of the database queries. - :type exempt_principals: str - :ivar application_principals: The list of the application principals. This is a legacy - parameter and is no longer used. - :vartype application_principals: str - :ivar masking_level: The masking level. This is a legacy parameter and is no longer used. - :vartype masking_level: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'kind': {'readonly': True}, - 'application_principals': {'readonly': True}, - 'masking_level': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'data_masking_state': {'key': 'properties.dataMaskingState', 'type': 'str'}, - 'exempt_principals': {'key': 'properties.exemptPrincipals', 'type': 'str'}, - 'application_principals': {'key': 'properties.applicationPrincipals', 'type': 'str'}, - 'masking_level': {'key': 'properties.maskingLevel', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataMaskingPolicy, self).__init__(**kwargs) - self.location = None - self.kind = None - self.data_masking_state = kwargs.get('data_masking_state', None) - self.exempt_principals = kwargs.get('exempt_principals', None) - self.application_principals = None - self.masking_level = None - - -class DataMaskingRule(ProxyResource): - """Represents a database data masking rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: The location of the data masking rule. - :vartype location: str - :ivar kind: The kind of Data Masking Rule. Metadata, used for Azure portal. - :vartype kind: str - :ivar id_properties_id: The rule Id. - :vartype id_properties_id: str - :param alias_name: The alias name. This is a legacy parameter and is no longer used. - :type alias_name: str - :param rule_state: The rule state. Used to delete a rule. To delete an existing rule, specify - the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. - However, if the rule doesn't already exist, the rule will be created with ruleState set to - enabled, regardless of the provided value of ruleState. Possible values include: "Disabled", - "Enabled". - :type rule_state: str or ~azure.mgmt.sql.models.DataMaskingRuleState - :param schema_name: The schema name on which the data masking rule is applied. - :type schema_name: str - :param table_name: The table name on which the data masking rule is applied. - :type table_name: str - :param column_name: The column name on which the data masking rule is applied. - :type column_name: str - :param masking_function: The masking function that is used for the data masking rule. Possible - values include: "Default", "CCN", "Email", "Number", "SSN", "Text". - :type masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction - :param number_from: The numberFrom property of the masking rule. Required if maskingFunction is - set to Number, otherwise this parameter will be ignored. - :type number_from: str - :param number_to: The numberTo property of the data masking rule. Required if maskingFunction - is set to Number, otherwise this parameter will be ignored. - :type number_to: str - :param prefix_size: If maskingFunction is set to Text, the number of characters to show - unmasked in the beginning of the string. Otherwise, this parameter will be ignored. - :type prefix_size: str - :param suffix_size: If maskingFunction is set to Text, the number of characters to show - unmasked at the end of the string. Otherwise, this parameter will be ignored. - :type suffix_size: str - :param replacement_string: If maskingFunction is set to Text, the character to use for masking - the unexposed part of the string. Otherwise, this parameter will be ignored. - :type replacement_string: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'kind': {'readonly': True}, - 'id_properties_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, - 'alias_name': {'key': 'properties.aliasName', 'type': 'str'}, - 'rule_state': {'key': 'properties.ruleState', 'type': 'str'}, - 'schema_name': {'key': 'properties.schemaName', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'column_name': {'key': 'properties.columnName', 'type': 'str'}, - 'masking_function': {'key': 'properties.maskingFunction', 'type': 'str'}, - 'number_from': {'key': 'properties.numberFrom', 'type': 'str'}, - 'number_to': {'key': 'properties.numberTo', 'type': 'str'}, - 'prefix_size': {'key': 'properties.prefixSize', 'type': 'str'}, - 'suffix_size': {'key': 'properties.suffixSize', 'type': 'str'}, - 'replacement_string': {'key': 'properties.replacementString', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataMaskingRule, self).__init__(**kwargs) - self.location = None - self.kind = None - self.id_properties_id = None - self.alias_name = kwargs.get('alias_name', None) - self.rule_state = kwargs.get('rule_state', None) - self.schema_name = kwargs.get('schema_name', None) - self.table_name = kwargs.get('table_name', None) - self.column_name = kwargs.get('column_name', None) - self.masking_function = kwargs.get('masking_function', None) - self.number_from = kwargs.get('number_from', None) - self.number_to = kwargs.get('number_to', None) - self.prefix_size = kwargs.get('prefix_size', None) - self.suffix_size = kwargs.get('suffix_size', None) - self.replacement_string = kwargs.get('replacement_string', None) - - -class DataMaskingRuleListResult(msrest.serialization.Model): - """The response to a list data masking rules request. - - :param value: The list of database data masking rules. - :type value: list[~azure.mgmt.sql.models.DataMaskingRule] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataMaskingRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataMaskingRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class DataWarehouseUserActivities(ProxyResource): - """User activities of a data warehouse. - - 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 active_queries_count: Count of running and suspended queries. - :vartype active_queries_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'active_queries_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'active_queries_count': {'key': 'properties.activeQueriesCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DataWarehouseUserActivities, self).__init__(**kwargs) - self.active_queries_count = None - - -class DataWarehouseUserActivitiesListResult(msrest.serialization.Model): - """User activities of a data warehouse. - - 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.DataWarehouseUserActivities] - :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': '[DataWarehouseUserActivities]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataWarehouseUserActivitiesListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Delegation(msrest.serialization.Model): - """Delegated Resource Properties - Internal Use Only. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param resource_id: The resource id of the source resource - Internal Use Only. - :type resource_id: str - :ivar tenant_id: AAD tenant guid of the source resource identity - Internal Use Only. - :vartype tenant_id: str - """ - - _validation = { - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Delegation, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.tenant_id = None - - -class DeletedServer(ProxyResource): - """A deleted server. - - 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 version: The version of the deleted server. - :vartype version: str - :ivar deletion_time: The deletion time of the deleted server. - :vartype deletion_time: ~datetime.datetime - :ivar original_id: The original ID of the server before deletion. - :vartype original_id: str - :ivar fully_qualified_domain_name: The fully qualified domain name of the server. - :vartype fully_qualified_domain_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'deletion_time': {'readonly': True}, - 'original_id': {'readonly': True}, - 'fully_qualified_domain_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'iso-8601'}, - 'original_id': {'key': 'properties.originalId', 'type': 'str'}, - 'fully_qualified_domain_name': {'key': 'properties.fullyQualifiedDomainName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DeletedServer, self).__init__(**kwargs) - self.version = None - self.deletion_time = None - self.original_id = None - self.fully_qualified_domain_name = None - - -class DeletedServerListResult(msrest.serialization.Model): - """A list of deleted servers. - - 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.DeletedServer] - :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': '[DeletedServer]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DeletedServerListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class EditionCapability(msrest.serialization.Model): - """The edition capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The database edition name. - :vartype name: str - :ivar supported_service_level_objectives: The list of supported service objectives for the - edition. - :vartype supported_service_level_objectives: - list[~azure.mgmt.sql.models.ServiceObjectiveCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the edition. - :vartype zone_redundant: bool - :ivar read_scale: The read scale capability for the edition. - :vartype read_scale: ~azure.mgmt.sql.models.ReadScaleCapability - :ivar supported_storage_capabilities: The list of supported storage capabilities for this - edition. - :vartype supported_storage_capabilities: list[~azure.mgmt.sql.models.StorageCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_service_level_objectives': {'readonly': True}, - 'zone_redundant': {'readonly': True}, - 'read_scale': {'readonly': True}, - 'supported_storage_capabilities': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_service_level_objectives': {'key': 'supportedServiceLevelObjectives', 'type': '[ServiceObjectiveCapability]'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'read_scale': {'key': 'readScale', 'type': 'ReadScaleCapability'}, - 'supported_storage_capabilities': {'key': 'supportedStorageCapabilities', 'type': '[StorageCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EditionCapability, self).__init__(**kwargs) - self.name = None - self.supported_service_level_objectives = None - self.zone_redundant = None - self.read_scale = None - self.supported_storage_capabilities = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ElasticPool(TrackedResource): - """An elastic pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The elastic pool SKU. - - The list of SKUs may vary by region and support offer. To determine the SKUs (including the - SKU name, tier/edition, family, and capacity) that are available to your subscription in an - Azure region, use the ``Capabilities_ListByLocation`` REST API or the following command: - - .. code-block:: azurecli - - az sql elastic-pool list-editions -l -o table - `. - :type sku: ~azure.mgmt.sql.models.Sku - :ivar kind: Kind of elastic pool. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar state: The state of the elastic pool. Possible values include: "Creating", "Ready", - "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.ElasticPoolState - :ivar creation_date: The creation date of the elastic pool (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :param max_size_bytes: The storage limit for the database elastic pool in bytes. - :type max_size_bytes: long - :param per_database_settings: The per database settings for the elastic pool. - :type per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :param zone_redundant: Whether or not this elastic pool is zone redundant, which means the - replicas of this elastic pool will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this elastic pool. Possible values include: - "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :param maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. - This configuration defines the period when the maintenance updates will will occur. - :type maintenance_configuration_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'state': {'readonly': True}, - 'creation_date': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'long'}, - 'per_database_settings': {'key': 'properties.perDatabaseSettings', 'type': 'ElasticPoolPerDatabaseSettings'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'license_type': {'key': 'properties.licenseType', 'type': 'str'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPool, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.kind = None - self.state = None - self.creation_date = None - self.max_size_bytes = kwargs.get('max_size_bytes', None) - self.per_database_settings = kwargs.get('per_database_settings', None) - self.zone_redundant = kwargs.get('zone_redundant', None) - self.license_type = kwargs.get('license_type', None) - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - - -class ElasticPoolActivity(ProxyResource): - """Represents the activity on an elastic pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :ivar end_time: The time the operation finished (ISO8601 format). - :vartype end_time: ~datetime.datetime - :ivar error_code: The error code if available. - :vartype error_code: int - :ivar error_message: The error message if available. - :vartype error_message: str - :ivar error_severity: The error severity if available. - :vartype error_severity: int - :ivar operation: The operation name. - :vartype operation: str - :ivar operation_id: The unique operation ID. - :vartype operation_id: str - :ivar percent_complete: The percentage complete if available. - :vartype percent_complete: int - :ivar requested_database_dtu_max: The requested max DTU per database if available. - :vartype requested_database_dtu_max: int - :ivar requested_database_dtu_min: The requested min DTU per database if available. - :vartype requested_database_dtu_min: int - :ivar requested_dtu: The requested DTU for the pool if available. - :vartype requested_dtu: int - :ivar requested_elastic_pool_name: The requested name for the elastic pool if available. - :vartype requested_elastic_pool_name: str - :ivar requested_storage_limit_in_gb: The requested storage limit for the pool in GB if - available. - :vartype requested_storage_limit_in_gb: long - :ivar elastic_pool_name: The name of the elastic pool. - :vartype elastic_pool_name: str - :ivar server_name: The name of the server the elastic pool is in. - :vartype server_name: str - :ivar start_time: The time the operation started (ISO8601 format). - :vartype start_time: ~datetime.datetime - :ivar state: The current state of the operation. - :vartype state: str - :ivar requested_storage_limit_in_mb: The requested storage limit in MB. - :vartype requested_storage_limit_in_mb: int - :ivar requested_database_dtu_guarantee: The requested per database DTU guarantee. - :vartype requested_database_dtu_guarantee: int - :ivar requested_database_dtu_cap: The requested per database DTU cap. - :vartype requested_database_dtu_cap: int - :ivar requested_dtu_guarantee: The requested DTU guarantee. - :vartype requested_dtu_guarantee: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'end_time': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'operation': {'readonly': True}, - 'operation_id': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'requested_database_dtu_max': {'readonly': True}, - 'requested_database_dtu_min': {'readonly': True}, - 'requested_dtu': {'readonly': True}, - 'requested_elastic_pool_name': {'readonly': True}, - 'requested_storage_limit_in_gb': {'readonly': True}, - 'elastic_pool_name': {'readonly': True}, - 'server_name': {'readonly': True}, - 'start_time': {'readonly': True}, - 'state': {'readonly': True}, - 'requested_storage_limit_in_mb': {'readonly': True}, - 'requested_database_dtu_guarantee': {'readonly': True}, - 'requested_database_dtu_cap': {'readonly': True}, - 'requested_dtu_guarantee': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, - 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, - 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'operation_id': {'key': 'properties.operationId', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'requested_database_dtu_max': {'key': 'properties.requestedDatabaseDtuMax', 'type': 'int'}, - 'requested_database_dtu_min': {'key': 'properties.requestedDatabaseDtuMin', 'type': 'int'}, - 'requested_dtu': {'key': 'properties.requestedDtu', 'type': 'int'}, - 'requested_elastic_pool_name': {'key': 'properties.requestedElasticPoolName', 'type': 'str'}, - 'requested_storage_limit_in_gb': {'key': 'properties.requestedStorageLimitInGB', 'type': 'long'}, - 'elastic_pool_name': {'key': 'properties.elasticPoolName', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'requested_storage_limit_in_mb': {'key': 'properties.requestedStorageLimitInMB', 'type': 'int'}, - 'requested_database_dtu_guarantee': {'key': 'properties.requestedDatabaseDtuGuarantee', 'type': 'int'}, - 'requested_database_dtu_cap': {'key': 'properties.requestedDatabaseDtuCap', 'type': 'int'}, - 'requested_dtu_guarantee': {'key': 'properties.requestedDtuGuarantee', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolActivity, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.end_time = None - self.error_code = None - self.error_message = None - self.error_severity = None - self.operation = None - self.operation_id = None - self.percent_complete = None - self.requested_database_dtu_max = None - self.requested_database_dtu_min = None - self.requested_dtu = None - self.requested_elastic_pool_name = None - self.requested_storage_limit_in_gb = None - self.elastic_pool_name = None - self.server_name = None - self.start_time = None - self.state = None - self.requested_storage_limit_in_mb = None - self.requested_database_dtu_guarantee = None - self.requested_database_dtu_cap = None - self.requested_dtu_guarantee = None - - -class ElasticPoolActivityListResult(msrest.serialization.Model): - """Represents the response to a list elastic pool activity request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of elastic pool activities. - :type value: list[~azure.mgmt.sql.models.ElasticPoolActivity] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ElasticPoolActivity]'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolActivityListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class ElasticPoolDatabaseActivity(ProxyResource): - """Represents the activity on an elastic pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :ivar database_name: The database name. - :vartype database_name: str - :ivar end_time: The time the operation finished (ISO8601 format). - :vartype end_time: ~datetime.datetime - :ivar error_code: The error code if available. - :vartype error_code: int - :ivar error_message: The error message if available. - :vartype error_message: str - :ivar error_severity: The error severity if available. - :vartype error_severity: int - :ivar operation: The operation name. - :vartype operation: str - :ivar operation_id: The unique operation ID. - :vartype operation_id: str - :ivar percent_complete: The percentage complete if available. - :vartype percent_complete: int - :ivar requested_elastic_pool_name: The name for the elastic pool the database is moving into if - available. - :vartype requested_elastic_pool_name: str - :ivar current_elastic_pool_name: The name of the current elastic pool the database is in if - available. - :vartype current_elastic_pool_name: str - :ivar current_service_objective: The name of the current service objective if available. - :vartype current_service_objective: str - :ivar requested_service_objective: The name of the requested service objective if available. - :vartype requested_service_objective: str - :ivar server_name: The name of the server the elastic pool is in. - :vartype server_name: str - :ivar start_time: The time the operation started (ISO8601 format). - :vartype start_time: ~datetime.datetime - :ivar state: The current state of the operation. - :vartype state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'database_name': {'readonly': True}, - 'end_time': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'operation': {'readonly': True}, - 'operation_id': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'requested_elastic_pool_name': {'readonly': True}, - 'current_elastic_pool_name': {'readonly': True}, - 'current_service_objective': {'readonly': True}, - 'requested_service_objective': {'readonly': True}, - 'server_name': {'readonly': True}, - 'start_time': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, - 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, - 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'operation_id': {'key': 'properties.operationId', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'requested_elastic_pool_name': {'key': 'properties.requestedElasticPoolName', 'type': 'str'}, - 'current_elastic_pool_name': {'key': 'properties.currentElasticPoolName', 'type': 'str'}, - 'current_service_objective': {'key': 'properties.currentServiceObjective', 'type': 'str'}, - 'requested_service_objective': {'key': 'properties.requestedServiceObjective', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolDatabaseActivity, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.database_name = None - self.end_time = None - self.error_code = None - self.error_message = None - self.error_severity = None - self.operation = None - self.operation_id = None - self.percent_complete = None - self.requested_elastic_pool_name = None - self.current_elastic_pool_name = None - self.current_service_objective = None - self.requested_service_objective = None - self.server_name = None - self.start_time = None - self.state = None - - -class ElasticPoolDatabaseActivityListResult(msrest.serialization.Model): - """Represents the response to a list elastic pool database activity request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of elastic pool database activities. - :type value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ElasticPoolDatabaseActivity]'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolDatabaseActivityListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class ElasticPoolEditionCapability(msrest.serialization.Model): - """The elastic pool edition capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The elastic pool edition name. - :vartype name: str - :ivar supported_elastic_pool_performance_levels: The list of supported elastic pool DTU levels - for the edition. - :vartype supported_elastic_pool_performance_levels: - list[~azure.mgmt.sql.models.ElasticPoolPerformanceLevelCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the edition. - :vartype zone_redundant: bool - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_elastic_pool_performance_levels': {'readonly': True}, - 'zone_redundant': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_elastic_pool_performance_levels': {'key': 'supportedElasticPoolPerformanceLevels', 'type': '[ElasticPoolPerformanceLevelCapability]'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolEditionCapability, self).__init__(**kwargs) - self.name = None - self.supported_elastic_pool_performance_levels = None - self.zone_redundant = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ElasticPoolListResult(msrest.serialization.Model): - """The result of an elastic pool list request. - - 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.ElasticPool] - :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': '[ElasticPool]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ElasticPoolOperation(ProxyResource): - """A elastic pool operation. - - 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 elastic_pool_name: The name of the elastic pool the operation is being performed on. - :vartype elastic_pool_name: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar server_name: The name of the server. - :vartype server_name: str - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. - :vartype state: str - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'elastic_pool_name': {'readonly': True}, - 'operation': {'readonly': True}, - 'operation_friendly_name': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'server_name': {'readonly': True}, - 'start_time': {'readonly': True}, - 'state': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_description': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'is_user_error': {'readonly': True}, - 'estimated_completion_time': {'readonly': True}, - 'description': {'readonly': True}, - 'is_cancellable': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'elastic_pool_name': {'key': 'properties.elasticPoolName', 'type': 'str'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'operation_friendly_name': {'key': 'properties.operationFriendlyName', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, - 'error_description': {'key': 'properties.errorDescription', 'type': 'str'}, - 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, - 'is_user_error': {'key': 'properties.isUserError', 'type': 'bool'}, - 'estimated_completion_time': {'key': 'properties.estimatedCompletionTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_cancellable': {'key': 'properties.isCancellable', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolOperation, self).__init__(**kwargs) - self.elastic_pool_name = None - self.operation = None - self.operation_friendly_name = None - self.percent_complete = None - self.server_name = None - self.start_time = None - self.state = None - self.error_code = None - self.error_description = None - self.error_severity = None - self.is_user_error = None - self.estimated_completion_time = None - self.description = None - self.is_cancellable = None - - -class ElasticPoolOperationListResult(msrest.serialization.Model): - """The response to a list elastic pool operations request. - - 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.ElasticPoolOperation] - :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': '[ElasticPoolOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolOperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ElasticPoolPerDatabaseMaxPerformanceLevelCapability(msrest.serialization.Model): - """The max per-database performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The maximum performance level per database. - :vartype limit: float - :ivar unit: Unit type used to measure performance level. Possible values include: "DTU", - "VCores". - :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit - :ivar supported_per_database_min_performance_levels: The list of supported min database - performance levels. - :vartype supported_per_database_min_performance_levels: - list[~azure.mgmt.sql.models.ElasticPoolPerDatabaseMinPerformanceLevelCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - 'supported_per_database_min_performance_levels': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'limit': {'key': 'limit', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'supported_per_database_min_performance_levels': {'key': 'supportedPerDatabaseMinPerformanceLevels', 'type': '[ElasticPoolPerDatabaseMinPerformanceLevelCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolPerDatabaseMaxPerformanceLevelCapability, self).__init__(**kwargs) - self.limit = None - self.unit = None - self.supported_per_database_min_performance_levels = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ElasticPoolPerDatabaseMinPerformanceLevelCapability(msrest.serialization.Model): - """The minimum per-database performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The minimum performance level per database. - :vartype limit: float - :ivar unit: Unit type used to measure performance level. Possible values include: "DTU", - "VCores". - :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'limit': {'key': 'limit', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolPerDatabaseMinPerformanceLevelCapability, self).__init__(**kwargs) - self.limit = None - self.unit = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ElasticPoolPerDatabaseSettings(msrest.serialization.Model): - """Per database settings of an elastic pool. - - :param min_capacity: The minimum capacity all databases are guaranteed. - :type min_capacity: float - :param max_capacity: The maximum capacity any one database can consume. - :type max_capacity: float - """ - - _attribute_map = { - 'min_capacity': {'key': 'minCapacity', 'type': 'float'}, - 'max_capacity': {'key': 'maxCapacity', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolPerDatabaseSettings, self).__init__(**kwargs) - self.min_capacity = kwargs.get('min_capacity', None) - self.max_capacity = kwargs.get('max_capacity', None) - - -class ElasticPoolPerformanceLevelCapability(msrest.serialization.Model): - """The Elastic Pool performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar performance_level: The performance level for the pool. - :vartype performance_level: ~azure.mgmt.sql.models.PerformanceLevelCapability - :ivar sku: The sku. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar max_database_count: The maximum number of databases supported. - :vartype max_database_count: int - :ivar included_max_size: The included (free) max size for this performance level. - :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar supported_max_sizes: The list of supported max sizes. - :vartype supported_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar supported_per_database_max_sizes: The list of supported per database max sizes. - :vartype supported_per_database_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar supported_per_database_max_performance_levels: The list of supported per database max - performance levels. - :vartype supported_per_database_max_performance_levels: - list[~azure.mgmt.sql.models.ElasticPoolPerDatabaseMaxPerformanceLevelCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the performance level. - :vartype zone_redundant: bool - :ivar supported_maintenance_configurations: List of supported maintenance configurations. - :vartype supported_maintenance_configurations: - list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'performance_level': {'readonly': True}, - 'sku': {'readonly': True}, - 'supported_license_types': {'readonly': True}, - 'max_database_count': {'readonly': True}, - 'included_max_size': {'readonly': True}, - 'supported_max_sizes': {'readonly': True}, - 'supported_per_database_max_sizes': {'readonly': True}, - 'supported_per_database_max_performance_levels': {'readonly': True}, - 'zone_redundant': {'readonly': True}, - 'supported_maintenance_configurations': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'performance_level': {'key': 'performanceLevel', 'type': 'PerformanceLevelCapability'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'supported_license_types': {'key': 'supportedLicenseTypes', 'type': '[LicenseTypeCapability]'}, - 'max_database_count': {'key': 'maxDatabaseCount', 'type': 'int'}, - 'included_max_size': {'key': 'includedMaxSize', 'type': 'MaxSizeCapability'}, - 'supported_max_sizes': {'key': 'supportedMaxSizes', 'type': '[MaxSizeRangeCapability]'}, - 'supported_per_database_max_sizes': {'key': 'supportedPerDatabaseMaxSizes', 'type': '[MaxSizeRangeCapability]'}, - 'supported_per_database_max_performance_levels': {'key': 'supportedPerDatabaseMaxPerformanceLevels', 'type': '[ElasticPoolPerDatabaseMaxPerformanceLevelCapability]'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'supported_maintenance_configurations': {'key': 'supportedMaintenanceConfigurations', 'type': '[MaintenanceConfigurationCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolPerformanceLevelCapability, self).__init__(**kwargs) - self.performance_level = None - self.sku = None - self.supported_license_types = None - self.max_database_count = None - self.included_max_size = None - self.supported_max_sizes = None - self.supported_per_database_max_sizes = None - self.supported_per_database_max_performance_levels = None - self.zone_redundant = None - self.supported_maintenance_configurations = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ElasticPoolUpdate(msrest.serialization.Model): - """An elastic pool update. - - :param sku: An ARM Resource SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param max_size_bytes: The storage limit for the database elastic pool in bytes. - :type max_size_bytes: long - :param per_database_settings: The per database settings for the elastic pool. - :type per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :param zone_redundant: Whether or not this elastic pool is zone redundant, which means the - replicas of this elastic pool will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this elastic pool. Possible values include: - "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :param maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. - This configuration defines the period when the maintenance updates will will occur. - :type maintenance_configuration_id: str - """ - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'long'}, - 'per_database_settings': {'key': 'properties.perDatabaseSettings', 'type': 'ElasticPoolPerDatabaseSettings'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'license_type': {'key': 'properties.licenseType', 'type': 'str'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ElasticPoolUpdate, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.tags = kwargs.get('tags', None) - self.max_size_bytes = kwargs.get('max_size_bytes', None) - self.per_database_settings = kwargs.get('per_database_settings', None) - self.zone_redundant = kwargs.get('zone_redundant', None) - self.license_type = kwargs.get('license_type', None) - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - - -class EncryptionProtector(ProxyResource): - """The server encryption protector. - - 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 kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar subregion: Subregion of the encryption protector. - :vartype subregion: str - :param server_key_name: The name of the server key. - :type server_key_name: str - :param server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Possible values include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :ivar uri: The URI of the server key. - :vartype uri: str - :ivar thumbprint: Thumbprint of the server key. - :vartype thumbprint: str - :param auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :type auto_rotation_enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, - 'subregion': {'readonly': True}, - 'uri': {'readonly': True}, - 'thumbprint': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'subregion': {'key': 'properties.subregion', 'type': 'str'}, - 'server_key_name': {'key': 'properties.serverKeyName', 'type': 'str'}, - 'server_key_type': {'key': 'properties.serverKeyType', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'auto_rotation_enabled': {'key': 'properties.autoRotationEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(EncryptionProtector, self).__init__(**kwargs) - self.kind = None - self.location = None - self.subregion = None - self.server_key_name = kwargs.get('server_key_name', None) - self.server_key_type = kwargs.get('server_key_type', None) - self.uri = None - self.thumbprint = None - self.auto_rotation_enabled = kwargs.get('auto_rotation_enabled', None) - - -class EncryptionProtectorListResult(msrest.serialization.Model): - """A list of server encryption protectors. - - 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.EncryptionProtector] - :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': '[EncryptionProtector]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EncryptionProtectorListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ExportDatabaseDefinition(msrest.serialization.Model): - """Contains the information necessary to perform export database operation. - - All required parameters must be populated in order to send to Azure. - - :param storage_key_type: Required. Storage key type. Possible values include: - "SharedAccessKey", "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Required. Storage key. - :type storage_key: str - :param storage_uri: Required. Storage Uri. - :type storage_uri: str - :param administrator_login: Required. Administrator login name. - :type administrator_login: str - :param administrator_login_password: Required. Administrator login password. - :type administrator_login_password: str - :param authentication_type: Authentication type. - :type authentication_type: str - :param network_isolation: Optional resource information to enable network isolation for - request. - :type network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - - _validation = { - 'storage_key_type': {'required': True}, - 'storage_key': {'required': True}, - 'storage_uri': {'required': True}, - 'administrator_login': {'required': True}, - 'administrator_login_password': {'required': True}, - } - - _attribute_map = { - 'storage_key_type': {'key': 'storageKeyType', 'type': 'str'}, - 'storage_key': {'key': 'storageKey', 'type': 'str'}, - 'storage_uri': {'key': 'storageUri', 'type': 'str'}, - 'administrator_login': {'key': 'administratorLogin', 'type': 'str'}, - 'administrator_login_password': {'key': 'administratorLoginPassword', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'network_isolation': {'key': 'networkIsolation', 'type': 'NetworkIsolationSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(ExportDatabaseDefinition, self).__init__(**kwargs) - self.storage_key_type = kwargs['storage_key_type'] - self.storage_key = kwargs['storage_key'] - self.storage_uri = kwargs['storage_uri'] - self.administrator_login = kwargs['administrator_login'] - self.administrator_login_password = kwargs['administrator_login_password'] - self.authentication_type = kwargs.get('authentication_type', None) - self.network_isolation = kwargs.get('network_isolation', None) - - -class ExtendedDatabaseBlobAuditingPolicy(ProxyResource): - """An extended database blob auditing policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param predicate_expression: Specifies condition of where clause when creating an audit. - :type predicate_expression: str - :param retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'predicate_expression': {'key': 'properties.predicateExpression', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'queue_delay_ms': {'key': 'properties.queueDelayMs', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtendedDatabaseBlobAuditingPolicy, self).__init__(**kwargs) - self.predicate_expression = kwargs.get('predicate_expression', None) - self.retention_days = kwargs.get('retention_days', None) - self.audit_actions_and_groups = kwargs.get('audit_actions_and_groups', None) - self.is_storage_secondary_key_in_use = kwargs.get('is_storage_secondary_key_in_use', None) - self.is_azure_monitor_target_enabled = kwargs.get('is_azure_monitor_target_enabled', None) - self.queue_delay_ms = kwargs.get('queue_delay_ms', None) - self.state = kwargs.get('state', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.storage_account_subscription_id = kwargs.get('storage_account_subscription_id', None) - - -class ExtendedDatabaseBlobAuditingPolicyListResult(msrest.serialization.Model): - """A list of database extended auditing 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.ExtendedDatabaseBlobAuditingPolicy] - :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': '[ExtendedDatabaseBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtendedDatabaseBlobAuditingPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ExtendedServerBlobAuditingPolicy(ProxyResource): - """An extended server blob auditing policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, - devops logs will be sent to Azure Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled', - 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - - When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should also be created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :type is_devops_audit_enabled: bool - :param predicate_expression: Specifies condition of where clause when creating an audit. - :type predicate_expression: str - :param retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_devops_audit_enabled': {'key': 'properties.isDevopsAuditEnabled', 'type': 'bool'}, - 'predicate_expression': {'key': 'properties.predicateExpression', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'queue_delay_ms': {'key': 'properties.queueDelayMs', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtendedServerBlobAuditingPolicy, self).__init__(**kwargs) - self.is_devops_audit_enabled = kwargs.get('is_devops_audit_enabled', None) - self.predicate_expression = kwargs.get('predicate_expression', None) - self.retention_days = kwargs.get('retention_days', None) - self.audit_actions_and_groups = kwargs.get('audit_actions_and_groups', None) - self.is_storage_secondary_key_in_use = kwargs.get('is_storage_secondary_key_in_use', None) - self.is_azure_monitor_target_enabled = kwargs.get('is_azure_monitor_target_enabled', None) - self.queue_delay_ms = kwargs.get('queue_delay_ms', None) - self.state = kwargs.get('state', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.storage_account_subscription_id = kwargs.get('storage_account_subscription_id', None) - - -class ExtendedServerBlobAuditingPolicyListResult(msrest.serialization.Model): - """A list of server extended auditing 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.ExtendedServerBlobAuditingPolicy] - :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': '[ExtendedServerBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtendedServerBlobAuditingPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class FailoverGroup(ProxyResource): - """A failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param read_write_endpoint: Read-write endpoint of the failover group instance. - :type read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :param read_only_endpoint: Read-only endpoint of the failover group instance. - :type read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint - :ivar replication_role: Local replication role of the failover group instance. Possible values - include: "Primary", "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.FailoverGroupReplicationRole - :ivar replication_state: Replication state of the failover group instance. - :vartype replication_state: str - :param partner_servers: List of partner server information for the failover group. - :type partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] - :param databases: List of databases in the failover group. - :type databases: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'replication_role': {'readonly': True}, - 'replication_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'read_write_endpoint': {'key': 'properties.readWriteEndpoint', 'type': 'FailoverGroupReadWriteEndpoint'}, - 'read_only_endpoint': {'key': 'properties.readOnlyEndpoint', 'type': 'FailoverGroupReadOnlyEndpoint'}, - 'replication_role': {'key': 'properties.replicationRole', 'type': 'str'}, - 'replication_state': {'key': 'properties.replicationState', 'type': 'str'}, - 'partner_servers': {'key': 'properties.partnerServers', 'type': '[PartnerInfo]'}, - 'databases': {'key': 'properties.databases', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverGroup, self).__init__(**kwargs) - self.location = None - self.tags = kwargs.get('tags', None) - self.read_write_endpoint = kwargs.get('read_write_endpoint', None) - self.read_only_endpoint = kwargs.get('read_only_endpoint', None) - self.replication_role = None - self.replication_state = None - self.partner_servers = kwargs.get('partner_servers', None) - self.databases = kwargs.get('databases', None) - - -class FailoverGroupListResult(msrest.serialization.Model): - """A list of failover groups. - - 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.FailoverGroup] - :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': '[FailoverGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverGroupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class FailoverGroupReadOnlyEndpoint(msrest.serialization.Model): - """Read-only endpoint of the failover group instance. - - :param failover_policy: Failover policy of the read-only endpoint for the failover group. - Possible values include: "Disabled", "Enabled". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy - """ - - _attribute_map = { - 'failover_policy': {'key': 'failoverPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverGroupReadOnlyEndpoint, self).__init__(**kwargs) - self.failover_policy = kwargs.get('failover_policy', None) - - -class FailoverGroupReadWriteEndpoint(msrest.serialization.Model): - """Read-write endpoint of the failover group instance. - - All required parameters must be populated in order to send to Azure. - - :param failover_policy: Required. Failover policy of the read-write endpoint for the failover - group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. - Possible values include: "Manual", "Automatic". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :param failover_with_data_loss_grace_period_minutes: Grace period before failover with data - loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then - failoverWithDataLossGracePeriodMinutes is required. - :type failover_with_data_loss_grace_period_minutes: int - """ - - _validation = { - 'failover_policy': {'required': True}, - } - - _attribute_map = { - 'failover_policy': {'key': 'failoverPolicy', 'type': 'str'}, - 'failover_with_data_loss_grace_period_minutes': {'key': 'failoverWithDataLossGracePeriodMinutes', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverGroupReadWriteEndpoint, self).__init__(**kwargs) - self.failover_policy = kwargs['failover_policy'] - self.failover_with_data_loss_grace_period_minutes = kwargs.get('failover_with_data_loss_grace_period_minutes', None) - - -class FailoverGroupUpdate(msrest.serialization.Model): - """A failover group update request. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param read_write_endpoint: Read-write endpoint of the failover group instance. - :type read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :param read_only_endpoint: Read-only endpoint of the failover group instance. - :type read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint - :param databases: List of databases in the failover group. - :type databases: list[str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'read_write_endpoint': {'key': 'properties.readWriteEndpoint', 'type': 'FailoverGroupReadWriteEndpoint'}, - 'read_only_endpoint': {'key': 'properties.readOnlyEndpoint', 'type': 'FailoverGroupReadOnlyEndpoint'}, - 'databases': {'key': 'properties.databases', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverGroupUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.read_write_endpoint = kwargs.get('read_write_endpoint', None) - self.read_only_endpoint = kwargs.get('read_only_endpoint', None) - self.databases = kwargs.get('databases', None) - - -class ResourceWithWritableName(msrest.serialization.Model): - """ARM resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :param name: Resource name. - :type name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceWithWritableName, self).__init__(**kwargs) - self.id = None - self.name = kwargs.get('name', None) - self.type = None - - -class ProxyResourceWithWritableName(ResourceWithWritableName): - """ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :param name: Resource name. - :type name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResourceWithWritableName, self).__init__(**kwargs) - - -class FirewallRule(ProxyResourceWithWritableName): - """A server firewall rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :param name: Resource name. - :type name: str - :ivar type: Resource type. - :vartype type: str - :param start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. Use - value '0.0.0.0' for all Azure-internal IP addresses. - :type start_ip_address: str - :param end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be - greater than or equal to startIpAddress. Use value '0.0.0.0' for all Azure-internal IP - addresses. - :type end_ip_address: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start_ip_address': {'key': 'properties.startIpAddress', 'type': 'str'}, - 'end_ip_address': {'key': 'properties.endIpAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FirewallRule, self).__init__(**kwargs) - self.start_ip_address = kwargs.get('start_ip_address', None) - self.end_ip_address = kwargs.get('end_ip_address', None) - - -class FirewallRuleList(msrest.serialization.Model): - """A list of server firewall rules. - - :param values: - :type values: list[~azure.mgmt.sql.models.FirewallRule] - """ - - _attribute_map = { - 'values': {'key': 'values', 'type': '[FirewallRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(FirewallRuleList, self).__init__(**kwargs) - self.values = kwargs.get('values', None) - - -class FirewallRuleListResult(msrest.serialization.Model): - """The response to a list firewall rules request. - - 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.FirewallRule] - :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': '[FirewallRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FirewallRuleListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class GeoBackupPolicy(ProxyResource): - """A database geo backup policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Kind of geo backup policy. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar location: Backup policy location. - :vartype location: str - :param state: Required. The state of the geo backup policy. Possible values include: - "Disabled", "Enabled". - :type state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState - :ivar storage_type: The storage type of the geo backup policy. - :vartype storage_type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, - 'state': {'required': True}, - 'storage_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GeoBackupPolicy, self).__init__(**kwargs) - self.kind = None - self.location = None - self.state = kwargs['state'] - self.storage_type = None - - -class GeoBackupPolicyListResult(msrest.serialization.Model): - """The response to a list geo backup policies request. - - :param value: The list of geo backup policies. - :type value: list[~azure.mgmt.sql.models.GeoBackupPolicy] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GeoBackupPolicy]'}, - } - - def __init__( - self, - **kwargs - ): - super(GeoBackupPolicyListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ImportExistingDatabaseDefinition(msrest.serialization.Model): - """Contains the information necessary to perform import operation for existing database. - - All required parameters must be populated in order to send to Azure. - - :param storage_key_type: Required. Storage key type. Possible values include: - "SharedAccessKey", "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Required. Storage key. - :type storage_key: str - :param storage_uri: Required. Storage Uri. - :type storage_uri: str - :param administrator_login: Required. Administrator login name. - :type administrator_login: str - :param administrator_login_password: Required. Administrator login password. - :type administrator_login_password: str - :param authentication_type: Authentication type. - :type authentication_type: str - :param network_isolation: Optional resource information to enable network isolation for - request. - :type network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - - _validation = { - 'storage_key_type': {'required': True}, - 'storage_key': {'required': True}, - 'storage_uri': {'required': True}, - 'administrator_login': {'required': True}, - 'administrator_login_password': {'required': True}, - } - - _attribute_map = { - 'storage_key_type': {'key': 'storageKeyType', 'type': 'str'}, - 'storage_key': {'key': 'storageKey', 'type': 'str'}, - 'storage_uri': {'key': 'storageUri', 'type': 'str'}, - 'administrator_login': {'key': 'administratorLogin', 'type': 'str'}, - 'administrator_login_password': {'key': 'administratorLoginPassword', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'network_isolation': {'key': 'networkIsolation', 'type': 'NetworkIsolationSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportExistingDatabaseDefinition, self).__init__(**kwargs) - self.storage_key_type = kwargs['storage_key_type'] - self.storage_key = kwargs['storage_key'] - self.storage_uri = kwargs['storage_uri'] - self.administrator_login = kwargs['administrator_login'] - self.administrator_login_password = kwargs['administrator_login_password'] - self.authentication_type = kwargs.get('authentication_type', None) - self.network_isolation = kwargs.get('network_isolation', None) - - -class ImportExportExtensionsOperationListResult(msrest.serialization.Model): - """Import export operation extensions list. - - 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.ImportExportExtensionsOperationResult] - :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': '[ImportExportExtensionsOperationResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportExportExtensionsOperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ImportExportExtensionsOperationResult(ProxyResource): - """An Extension operation result resource. - - 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 request_id: Request Id. - :vartype request_id: str - :ivar request_type: Request type. - :vartype request_type: str - :ivar last_modified_time: Last modified time. - :vartype last_modified_time: str - :ivar server_name: Server name. - :vartype server_name: str - :ivar database_name: Database name. - :vartype database_name: str - :ivar status: Operation status. - :vartype status: str - :ivar error_message: Error message. - :vartype error_message: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'request_id': {'readonly': True}, - 'request_type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'server_name': {'readonly': True}, - 'database_name': {'readonly': True}, - 'status': {'readonly': True}, - 'error_message': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'request_id': {'key': 'properties.requestId', 'type': 'str'}, - 'request_type': {'key': 'properties.requestType', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportExportExtensionsOperationResult, self).__init__(**kwargs) - self.request_id = None - self.request_type = None - self.last_modified_time = None - self.server_name = None - self.database_name = None - self.status = None - self.error_message = None - - -class ImportExportOperationResult(ProxyResource): - """An ImportExport operation result resource. - - 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 request_id: Request Id. - :vartype request_id: str - :ivar request_type: Request type. - :vartype request_type: str - :ivar queued_time: Queued time. - :vartype queued_time: str - :ivar last_modified_time: Last modified time. - :vartype last_modified_time: str - :ivar blob_uri: Blob Uri. - :vartype blob_uri: str - :ivar server_name: Server name. - :vartype server_name: str - :ivar database_name: Database name. - :vartype database_name: str - :ivar status: Operation status. - :vartype status: str - :ivar error_message: Error message. - :vartype error_message: str - :ivar private_endpoint_connections: Gets the status of private endpoints associated with this - request. - :vartype private_endpoint_connections: - list[~azure.mgmt.sql.models.PrivateEndpointConnectionRequestStatus] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'request_id': {'readonly': True}, - 'request_type': {'readonly': True}, - 'queued_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'blob_uri': {'readonly': True}, - 'server_name': {'readonly': True}, - 'database_name': {'readonly': True}, - 'status': {'readonly': True}, - 'error_message': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'request_id': {'key': 'properties.requestId', 'type': 'str'}, - 'request_type': {'key': 'properties.requestType', 'type': 'str'}, - 'queued_time': {'key': 'properties.queuedTime', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, - 'blob_uri': {'key': 'properties.blobUri', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnectionRequestStatus]'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportExportOperationResult, self).__init__(**kwargs) - self.request_id = None - self.request_type = None - self.queued_time = None - self.last_modified_time = None - self.blob_uri = None - self.server_name = None - self.database_name = None - self.status = None - self.error_message = None - self.private_endpoint_connections = None - - -class ImportNewDatabaseDefinition(msrest.serialization.Model): - """Contains the information necessary to perform import operation for new database. - - All required parameters must be populated in order to send to Azure. - - :param database_name: Name of the import database. - :type database_name: str - :param edition: Edition of the import database. - :type edition: str - :param service_objective_name: Service level objective name of the import database. - :type service_objective_name: str - :param max_size_bytes: Max size in bytes for the import database. - :type max_size_bytes: str - :param storage_key_type: Required. Storage key type. Possible values include: - "SharedAccessKey", "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Required. Storage key. - :type storage_key: str - :param storage_uri: Required. Storage Uri. - :type storage_uri: str - :param administrator_login: Required. Administrator login name. - :type administrator_login: str - :param administrator_login_password: Required. Administrator login password. - :type administrator_login_password: str - :param authentication_type: Authentication type. - :type authentication_type: str - :param network_isolation: Optional resource information to enable network isolation for - request. - :type network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - - _validation = { - 'storage_key_type': {'required': True}, - 'storage_key': {'required': True}, - 'storage_uri': {'required': True}, - 'administrator_login': {'required': True}, - 'administrator_login_password': {'required': True}, - } - - _attribute_map = { - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'edition': {'key': 'edition', 'type': 'str'}, - 'service_objective_name': {'key': 'serviceObjectiveName', 'type': 'str'}, - 'max_size_bytes': {'key': 'maxSizeBytes', 'type': 'str'}, - 'storage_key_type': {'key': 'storageKeyType', 'type': 'str'}, - 'storage_key': {'key': 'storageKey', 'type': 'str'}, - 'storage_uri': {'key': 'storageUri', 'type': 'str'}, - 'administrator_login': {'key': 'administratorLogin', 'type': 'str'}, - 'administrator_login_password': {'key': 'administratorLoginPassword', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'network_isolation': {'key': 'networkIsolation', 'type': 'NetworkIsolationSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportNewDatabaseDefinition, self).__init__(**kwargs) - self.database_name = kwargs.get('database_name', None) - self.edition = kwargs.get('edition', None) - self.service_objective_name = kwargs.get('service_objective_name', None) - self.max_size_bytes = kwargs.get('max_size_bytes', None) - self.storage_key_type = kwargs['storage_key_type'] - self.storage_key = kwargs['storage_key'] - self.storage_uri = kwargs['storage_uri'] - self.administrator_login = kwargs['administrator_login'] - self.administrator_login_password = kwargs['administrator_login_password'] - self.authentication_type = kwargs.get('authentication_type', None) - self.network_isolation = kwargs.get('network_isolation', None) - - -class InstanceFailoverGroup(ProxyResource): - """An instance failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param read_write_endpoint: Read-write endpoint of the failover group instance. - :type read_write_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint - :param read_only_endpoint: Read-only endpoint of the failover group instance. - :type read_only_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint - :ivar replication_role: Local replication role of the failover group instance. Possible values - include: "Primary", "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole - :ivar replication_state: Replication state of the failover group instance. - :vartype replication_state: str - :param partner_regions: Partner region information for the failover group. - :type partner_regions: list[~azure.mgmt.sql.models.PartnerRegionInfo] - :param managed_instance_pairs: List of managed instance pairs in the failover group. - :type managed_instance_pairs: list[~azure.mgmt.sql.models.ManagedInstancePairInfo] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'replication_role': {'readonly': True}, - 'replication_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'read_write_endpoint': {'key': 'properties.readWriteEndpoint', 'type': 'InstanceFailoverGroupReadWriteEndpoint'}, - 'read_only_endpoint': {'key': 'properties.readOnlyEndpoint', 'type': 'InstanceFailoverGroupReadOnlyEndpoint'}, - 'replication_role': {'key': 'properties.replicationRole', 'type': 'str'}, - 'replication_state': {'key': 'properties.replicationState', 'type': 'str'}, - 'partner_regions': {'key': 'properties.partnerRegions', 'type': '[PartnerRegionInfo]'}, - 'managed_instance_pairs': {'key': 'properties.managedInstancePairs', 'type': '[ManagedInstancePairInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(InstanceFailoverGroup, self).__init__(**kwargs) - self.read_write_endpoint = kwargs.get('read_write_endpoint', None) - self.read_only_endpoint = kwargs.get('read_only_endpoint', None) - self.replication_role = None - self.replication_state = None - self.partner_regions = kwargs.get('partner_regions', None) - self.managed_instance_pairs = kwargs.get('managed_instance_pairs', None) - - -class InstanceFailoverGroupListResult(msrest.serialization.Model): - """A list of instance failover groups. - - 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.InstanceFailoverGroup] - :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': '[InstanceFailoverGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstanceFailoverGroupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class InstanceFailoverGroupReadOnlyEndpoint(msrest.serialization.Model): - """Read-only endpoint of the failover group instance. - - :param failover_policy: Failover policy of the read-only endpoint for the failover group. - Possible values include: "Disabled", "Enabled". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy - """ - - _attribute_map = { - 'failover_policy': {'key': 'failoverPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstanceFailoverGroupReadOnlyEndpoint, self).__init__(**kwargs) - self.failover_policy = kwargs.get('failover_policy', None) - - -class InstanceFailoverGroupReadWriteEndpoint(msrest.serialization.Model): - """Read-write endpoint of the failover group instance. - - All required parameters must be populated in order to send to Azure. - - :param failover_policy: Required. Failover policy of the read-write endpoint for the failover - group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. - Possible values include: "Manual", "Automatic". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :param failover_with_data_loss_grace_period_minutes: Grace period before failover with data - loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then - failoverWithDataLossGracePeriodMinutes is required. - :type failover_with_data_loss_grace_period_minutes: int - """ - - _validation = { - 'failover_policy': {'required': True}, - } - - _attribute_map = { - 'failover_policy': {'key': 'failoverPolicy', 'type': 'str'}, - 'failover_with_data_loss_grace_period_minutes': {'key': 'failoverWithDataLossGracePeriodMinutes', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(InstanceFailoverGroupReadWriteEndpoint, self).__init__(**kwargs) - self.failover_policy = kwargs['failover_policy'] - self.failover_with_data_loss_grace_period_minutes = kwargs.get('failover_with_data_loss_grace_period_minutes', None) - - -class InstancePool(TrackedResource): - """An Azure SQL instance pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param subnet_id: Resource ID of the subnet to place this instance pool in. - :type subnet_id: str - :param v_cores: Count of vCores belonging to this instance pool. - :type v_cores: int - :param license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL - license is included) and 'BasePrice' (without SQL license price). Possible values include: - "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'subnet_id': {'key': 'properties.subnetId', 'type': 'str'}, - 'v_cores': {'key': 'properties.vCores', 'type': 'int'}, - 'license_type': {'key': 'properties.licenseType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstancePool, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.subnet_id = kwargs.get('subnet_id', None) - self.v_cores = kwargs.get('v_cores', None) - self.license_type = kwargs.get('license_type', None) - - -class InstancePoolEditionCapability(msrest.serialization.Model): - """The instance pool capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The instance pool version name. - :vartype name: str - :ivar supported_families: The supported families. - :vartype supported_families: list[~azure.mgmt.sql.models.InstancePoolFamilyCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_families': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_families': {'key': 'supportedFamilies', 'type': '[InstancePoolFamilyCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstancePoolEditionCapability, self).__init__(**kwargs) - self.name = None - self.supported_families = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class InstancePoolFamilyCapability(msrest.serialization.Model): - """The instance pool family capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Family name. - :vartype name: str - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar supported_vcores_values: List of supported virtual cores values. - :vartype supported_vcores_values: list[~azure.mgmt.sql.models.InstancePoolVcoresCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_license_types': {'readonly': True}, - 'supported_vcores_values': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_license_types': {'key': 'supportedLicenseTypes', 'type': '[LicenseTypeCapability]'}, - 'supported_vcores_values': {'key': 'supportedVcoresValues', 'type': '[InstancePoolVcoresCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstancePoolFamilyCapability, self).__init__(**kwargs) - self.name = None - self.supported_license_types = None - self.supported_vcores_values = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class InstancePoolListResult(msrest.serialization.Model): - """A list of Azure SQL instance pools. - - 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.InstancePool] - :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': '[InstancePool]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstancePoolListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class InstancePoolUpdate(msrest.serialization.Model): - """An update to an Instance pool. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(InstancePoolUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class InstancePoolVcoresCapability(msrest.serialization.Model): - """The managed instance virtual cores capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The virtual cores identifier. - :vartype name: str - :ivar value: The virtual cores value. - :vartype value: int - :ivar storage_limit: Storage limit. - :vartype storage_limit: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, - 'storage_limit': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, - 'storage_limit': {'key': 'storageLimit', 'type': 'MaxSizeCapability'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstancePoolVcoresCapability, self).__init__(**kwargs) - self.name = None - self.value = None - self.storage_limit = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class Job(ProxyResource): - """A job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param description: User-defined description of the job. - :type description: str - :ivar version: The job version number. - :vartype version: int - :param schedule: Schedule properties of the job. - :type schedule: ~azure.mgmt.sql.models.JobSchedule - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'int'}, - 'schedule': {'key': 'properties.schedule', 'type': 'JobSchedule'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.description = kwargs.get('description', "") - self.version = None - self.schedule = kwargs.get('schedule', None) - - -class JobAgent(TrackedResource): - """An Azure SQL job agent. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param database_id: Resource ID of the database to store job metadata in. - :type database_id: str - :ivar state: The state of the job agent. Possible values include: "Creating", "Ready", - "Updating", "Deleting", "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.JobAgentState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'database_id': {'key': 'properties.databaseId', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobAgent, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.database_id = kwargs.get('database_id', None) - self.state = None - - -class JobAgentListResult(msrest.serialization.Model): - """A list of Azure SQL job agents. - - 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.JobAgent] - :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': '[JobAgent]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobAgentListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class JobAgentUpdate(msrest.serialization.Model): - """An update to an Azure SQL job agent. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(JobAgentUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class JobCredential(ProxyResource): - """A stored credential that can be used by a job to connect to target databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param username: The credential user name. - :type username: str - :param password: The credential password. - :type password: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'username': {'key': 'properties.username', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobCredential, self).__init__(**kwargs) - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - - -class JobCredentialListResult(msrest.serialization.Model): - """A list of job credentials. - - 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.JobCredential] - :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': '[JobCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobCredentialListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class JobExecution(ProxyResource): - """An execution of a job. - - 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 job_version: The job version number. - :vartype job_version: int - :ivar step_name: The job step name. - :vartype step_name: str - :ivar step_id: The job step id. - :vartype step_id: int - :ivar job_execution_id: The unique identifier of the job execution. - :vartype job_execution_id: str - :ivar lifecycle: The detailed state of the job execution. Possible values include: "Created", - "InProgress", "WaitingForChildJobExecutions", "WaitingForRetry", "Succeeded", - "SucceededWithSkipped", "Failed", "TimedOut", "Canceled", "Skipped". - :vartype lifecycle: str or ~azure.mgmt.sql.models.JobExecutionLifecycle - :ivar provisioning_state: The ARM provisioning state of the job execution. Possible values - include: "Created", "InProgress", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState - :ivar create_time: The time that the job execution was created. - :vartype create_time: ~datetime.datetime - :ivar start_time: The time that the job execution started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The time that the job execution completed. - :vartype end_time: ~datetime.datetime - :param current_attempts: Number of times the job execution has been attempted. - :type current_attempts: int - :ivar current_attempt_start_time: Start time of the current attempt. - :vartype current_attempt_start_time: ~datetime.datetime - :ivar last_message: The last status or error message. - :vartype last_message: str - :ivar target: The target that this execution is executed on. - :vartype target: ~azure.mgmt.sql.models.JobExecutionTarget - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'job_version': {'readonly': True}, - 'step_name': {'readonly': True}, - 'step_id': {'readonly': True}, - 'job_execution_id': {'readonly': True}, - 'lifecycle': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'create_time': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'current_attempt_start_time': {'readonly': True}, - 'last_message': {'readonly': True}, - 'target': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'job_version': {'key': 'properties.jobVersion', 'type': 'int'}, - 'step_name': {'key': 'properties.stepName', 'type': 'str'}, - 'step_id': {'key': 'properties.stepId', 'type': 'int'}, - 'job_execution_id': {'key': 'properties.jobExecutionId', 'type': 'str'}, - 'lifecycle': {'key': 'properties.lifecycle', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'current_attempts': {'key': 'properties.currentAttempts', 'type': 'int'}, - 'current_attempt_start_time': {'key': 'properties.currentAttemptStartTime', 'type': 'iso-8601'}, - 'last_message': {'key': 'properties.lastMessage', 'type': 'str'}, - 'target': {'key': 'properties.target', 'type': 'JobExecutionTarget'}, - } - - def __init__( - self, - **kwargs - ): - super(JobExecution, self).__init__(**kwargs) - self.job_version = None - self.step_name = None - self.step_id = None - self.job_execution_id = None - self.lifecycle = None - self.provisioning_state = None - self.create_time = None - self.start_time = None - self.end_time = None - self.current_attempts = kwargs.get('current_attempts', None) - self.current_attempt_start_time = None - self.last_message = None - self.target = None - - -class JobExecutionListResult(msrest.serialization.Model): - """A list of job executions. - - 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.JobExecution] - :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': '[JobExecution]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobExecutionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class JobExecutionTarget(msrest.serialization.Model): - """The target that a job execution is executed on. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the target. Possible values include: "TargetGroup", "SqlDatabase", - "SqlElasticPool", "SqlShardMap", "SqlServer". - :vartype type: str or ~azure.mgmt.sql.models.JobTargetType - :ivar server_name: The server name. - :vartype server_name: str - :ivar database_name: The database name. - :vartype database_name: str - """ - - _validation = { - 'type': {'readonly': True}, - 'server_name': {'readonly': True}, - 'database_name': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'server_name': {'key': 'serverName', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobExecutionTarget, self).__init__(**kwargs) - self.type = None - self.server_name = None - self.database_name = None - - -class JobListResult(msrest.serialization.Model): - """A list of jobs. - - 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.Job] - :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': '[Job]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class JobSchedule(msrest.serialization.Model): - """Scheduling properties of a job. - - :param start_time: Schedule start time. - :type start_time: ~datetime.datetime - :param end_time: Schedule end time. - :type end_time: ~datetime.datetime - :param type: Schedule interval type. Possible values include: "Once", "Recurring". Default - value: "Once". - :type type: str or ~azure.mgmt.sql.models.JobScheduleType - :param enabled: Whether or not the schedule is enabled. - :type enabled: bool - :param interval: Value of the schedule's recurring interval, if the ScheduleType is recurring. - ISO8601 duration format. - :type interval: str - """ - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'type': {'key': 'type', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'interval': {'key': 'interval', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobSchedule, self).__init__(**kwargs) - self.start_time = kwargs.get('start_time', "0001-01-01T00:00:00+00:00") - self.end_time = kwargs.get('end_time', "9999-12-31T11:59:59+00:00") - self.type = kwargs.get('type', "Once") - self.enabled = kwargs.get('enabled', None) - self.interval = kwargs.get('interval', None) - - -class JobStep(ProxyResource): - """A job step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param step_id: The job step's index within the job. If not specified when creating the job - step, it will be created as the last step. If not specified when updating the job step, the - step id is not modified. - :type step_id: int - :param target_group: The resource ID of the target group that the job step will be executed on. - :type target_group: str - :param credential: The resource ID of the job credential that will be used to connect to the - targets. - :type credential: str - :param action: The action payload of the job step. - :type action: ~azure.mgmt.sql.models.JobStepAction - :param output: Output destination properties of the job step. - :type output: ~azure.mgmt.sql.models.JobStepOutput - :param execution_options: Execution options for the job step. - :type execution_options: ~azure.mgmt.sql.models.JobStepExecutionOptions - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'step_id': {'key': 'properties.stepId', 'type': 'int'}, - 'target_group': {'key': 'properties.targetGroup', 'type': 'str'}, - 'credential': {'key': 'properties.credential', 'type': 'str'}, - 'action': {'key': 'properties.action', 'type': 'JobStepAction'}, - 'output': {'key': 'properties.output', 'type': 'JobStepOutput'}, - 'execution_options': {'key': 'properties.executionOptions', 'type': 'JobStepExecutionOptions'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStep, self).__init__(**kwargs) - self.step_id = kwargs.get('step_id', None) - self.target_group = kwargs.get('target_group', None) - self.credential = kwargs.get('credential', None) - self.action = kwargs.get('action', None) - self.output = kwargs.get('output', None) - self.execution_options = kwargs.get('execution_options', None) - - -class JobStepAction(msrest.serialization.Model): - """The action to be executed by a job step. - - All required parameters must be populated in order to send to Azure. - - :param type: Type of action being executed by the job step. Possible values include: "TSql". - Default value: "TSql". - :type type: str or ~azure.mgmt.sql.models.JobStepActionType - :param source: The source of the action to execute. Possible values include: "Inline". Default - value: "Inline". - :type source: str or ~azure.mgmt.sql.models.JobStepActionSource - :param value: Required. The action value, for example the text of the T-SQL script to execute. - :type value: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStepAction, self).__init__(**kwargs) - self.type = kwargs.get('type', "TSql") - self.source = kwargs.get('source', "Inline") - self.value = kwargs['value'] - - -class JobStepExecutionOptions(msrest.serialization.Model): - """The execution options of a job step. - - :param timeout_seconds: Execution timeout for the job step. - :type timeout_seconds: int - :param retry_attempts: Maximum number of times the job step will be reattempted if the first - attempt fails. - :type retry_attempts: int - :param initial_retry_interval_seconds: Initial delay between retries for job step execution. - :type initial_retry_interval_seconds: int - :param maximum_retry_interval_seconds: The maximum amount of time to wait between retries for - job step execution. - :type maximum_retry_interval_seconds: int - :param retry_interval_backoff_multiplier: The backoff multiplier for the time between retries. - :type retry_interval_backoff_multiplier: float - """ - - _attribute_map = { - 'timeout_seconds': {'key': 'timeoutSeconds', 'type': 'int'}, - 'retry_attempts': {'key': 'retryAttempts', 'type': 'int'}, - 'initial_retry_interval_seconds': {'key': 'initialRetryIntervalSeconds', 'type': 'int'}, - 'maximum_retry_interval_seconds': {'key': 'maximumRetryIntervalSeconds', 'type': 'int'}, - 'retry_interval_backoff_multiplier': {'key': 'retryIntervalBackoffMultiplier', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStepExecutionOptions, self).__init__(**kwargs) - self.timeout_seconds = kwargs.get('timeout_seconds', 43200) - self.retry_attempts = kwargs.get('retry_attempts', 10) - self.initial_retry_interval_seconds = kwargs.get('initial_retry_interval_seconds', 1) - self.maximum_retry_interval_seconds = kwargs.get('maximum_retry_interval_seconds', 120) - self.retry_interval_backoff_multiplier = kwargs.get('retry_interval_backoff_multiplier', 2) - - -class JobStepListResult(msrest.serialization.Model): - """A list of job steps. - - 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.JobStep] - :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': '[JobStep]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStepListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class JobStepOutput(msrest.serialization.Model): - """The output configuration of a job step. - - All required parameters must be populated in order to send to Azure. - - :param type: The output destination type. Possible values include: "SqlDatabase". Default - value: "SqlDatabase". - :type type: str or ~azure.mgmt.sql.models.JobStepOutputType - :param subscription_id: The output destination subscription id. - :type subscription_id: str - :param resource_group_name: The output destination resource group. - :type resource_group_name: str - :param server_name: Required. The output destination server name. - :type server_name: str - :param database_name: Required. The output destination database. - :type database_name: str - :param schema_name: The output destination schema. - :type schema_name: str - :param table_name: Required. The output destination table. - :type table_name: str - :param credential: Required. The resource ID of the credential to use to connect to the output - destination. - :type credential: str - """ - - _validation = { - 'server_name': {'required': True}, - 'database_name': {'required': True}, - 'table_name': {'required': True}, - 'credential': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'server_name': {'key': 'serverName', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'schema_name': {'key': 'schemaName', 'type': 'str'}, - 'table_name': {'key': 'tableName', 'type': 'str'}, - 'credential': {'key': 'credential', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStepOutput, self).__init__(**kwargs) - self.type = kwargs.get('type', "SqlDatabase") - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group_name = kwargs.get('resource_group_name', None) - self.server_name = kwargs['server_name'] - self.database_name = kwargs['database_name'] - self.schema_name = kwargs.get('schema_name', "dbo") - self.table_name = kwargs['table_name'] - self.credential = kwargs['credential'] - - -class JobTarget(msrest.serialization.Model): - """A job target, for example a specific database or a container of databases that is evaluated during job execution. - - All required parameters must be populated in order to send to Azure. - - :param membership_type: Whether the target is included or excluded from the group. Possible - values include: "Include", "Exclude". Default value: "Include". - :type membership_type: str or ~azure.mgmt.sql.models.JobTargetGroupMembershipType - :param type: Required. The target type. Possible values include: "TargetGroup", "SqlDatabase", - "SqlElasticPool", "SqlShardMap", "SqlServer". - :type type: str or ~azure.mgmt.sql.models.JobTargetType - :param server_name: The target server name. - :type server_name: str - :param database_name: The target database name. - :type database_name: str - :param elastic_pool_name: The target elastic pool name. - :type elastic_pool_name: str - :param shard_map_name: The target shard map. - :type shard_map_name: str - :param refresh_credential: The resource ID of the credential that is used during job execution - to connect to the target and determine the list of databases inside the target. - :type refresh_credential: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'membership_type': {'key': 'membershipType', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'server_name': {'key': 'serverName', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'elastic_pool_name': {'key': 'elasticPoolName', 'type': 'str'}, - 'shard_map_name': {'key': 'shardMapName', 'type': 'str'}, - 'refresh_credential': {'key': 'refreshCredential', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobTarget, self).__init__(**kwargs) - self.membership_type = kwargs.get('membership_type', "Include") - self.type = kwargs['type'] - self.server_name = kwargs.get('server_name', None) - self.database_name = kwargs.get('database_name', None) - self.elastic_pool_name = kwargs.get('elastic_pool_name', None) - self.shard_map_name = kwargs.get('shard_map_name', None) - self.refresh_credential = kwargs.get('refresh_credential', None) - - -class JobTargetGroup(ProxyResource): - """A group of job targets. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param members: Members of the target group. - :type members: list[~azure.mgmt.sql.models.JobTarget] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'members': {'key': 'properties.members', 'type': '[JobTarget]'}, - } - - def __init__( - self, - **kwargs - ): - super(JobTargetGroup, self).__init__(**kwargs) - self.members = kwargs.get('members', None) - - -class JobTargetGroupListResult(msrest.serialization.Model): - """A list of target groups. - - 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.JobTargetGroup] - :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': '[JobTargetGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobTargetGroupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class JobVersion(ProxyResource): - """A job version. - - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobVersion, self).__init__(**kwargs) - - -class JobVersionListResult(msrest.serialization.Model): - """A list of job versions. - - 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.JobVersion] - :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': '[JobVersion]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobVersionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class LedgerDigestUploads(ProxyResource): - """Azure SQL Database ledger digest upload settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param digest_storage_endpoint: The digest storage endpoint, which must be either an Azure blob - storage endpoint or an URI for Azure Confidential Ledger. - :type digest_storage_endpoint: str - :ivar state: Specifies the state of ledger digest upload. Possible values include: "Enabled", - "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.LedgerDigestUploadsState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'digest_storage_endpoint': {'key': 'properties.digestStorageEndpoint', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LedgerDigestUploads, self).__init__(**kwargs) - self.digest_storage_endpoint = kwargs.get('digest_storage_endpoint', None) - self.state = None - - -class LedgerDigestUploadsListResult(msrest.serialization.Model): - """A list of ledger digest upload 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.LedgerDigestUploads] - :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': '[LedgerDigestUploads]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LedgerDigestUploadsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class LicenseTypeCapability(msrest.serialization.Model): - """The license type capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: License type identifier. - :vartype name: str - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LicenseTypeCapability, self).__init__(**kwargs) - self.name = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class LocationCapabilities(msrest.serialization.Model): - """The location capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The location name. - :vartype name: str - :ivar supported_server_versions: The list of supported server versions. - :vartype supported_server_versions: list[~azure.mgmt.sql.models.ServerVersionCapability] - :ivar supported_managed_instance_versions: The list of supported managed instance versions. - :vartype supported_managed_instance_versions: - list[~azure.mgmt.sql.models.ManagedInstanceVersionCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_server_versions': {'readonly': True}, - 'supported_managed_instance_versions': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_server_versions': {'key': 'supportedServerVersions', 'type': '[ServerVersionCapability]'}, - 'supported_managed_instance_versions': {'key': 'supportedManagedInstanceVersions', 'type': '[ManagedInstanceVersionCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationCapabilities, self).__init__(**kwargs) - self.name = None - self.supported_server_versions = None - self.supported_managed_instance_versions = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class LogicalDatabaseTransparentDataEncryption(ProxyResource): - """A logical database transparent data encryption state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param state: Specifies the state of the transparent data encryption. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicalDatabaseTransparentDataEncryption, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - - -class LogicalDatabaseTransparentDataEncryptionListResult(msrest.serialization.Model): - """A list of transparent data encryptions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LogicalDatabaseTransparentDataEncryption]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicalDatabaseTransparentDataEncryptionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class LogicalServerSecurityAlertPolicyListResult(msrest.serialization.Model): - """A list of the server's security alert policies. - - 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.ServerSecurityAlertPolicy] - :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': '[ServerSecurityAlertPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicalServerSecurityAlertPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class LogSizeCapability(msrest.serialization.Model): - """The log size capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The log size limit (see 'unit' for the units). - :vartype limit: int - :ivar unit: The units that the limit is expressed in. Possible values include: "Megabytes", - "Gigabytes", "Terabytes", "Petabytes", "Percent". - :vartype unit: str or ~azure.mgmt.sql.models.LogSizeUnit - """ - - _validation = { - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - } - - _attribute_map = { - 'limit': {'key': 'limit', 'type': 'int'}, - 'unit': {'key': 'unit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSizeCapability, self).__init__(**kwargs) - self.limit = None - self.unit = None - - -class LongTermRetentionBackup(ProxyResource): - """A long term retention backup. - - 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 server_name: The server name that the backup database belong to. - :vartype server_name: str - :ivar server_create_time: The create time of the server. - :vartype server_create_time: ~datetime.datetime - :ivar database_name: The name of the database the backup belong to. - :vartype database_name: str - :ivar database_deletion_time: The delete time of the database. - :vartype database_deletion_time: ~datetime.datetime - :ivar backup_time: The time the backup was taken. - :vartype backup_time: ~datetime.datetime - :ivar backup_expiration_time: The time the long term retention backup will expire. - :vartype backup_expiration_time: ~datetime.datetime - :ivar backup_storage_redundancy: The storage redundancy type of the backup. Possible values - include: "Geo", "Local", "Zone", "GeoZone". - :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage redundancy type of the backup. Possible - values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'server_name': {'readonly': True}, - 'server_create_time': {'readonly': True}, - 'database_name': {'readonly': True}, - 'database_deletion_time': {'readonly': True}, - 'backup_time': {'readonly': True}, - 'backup_expiration_time': {'readonly': True}, - 'backup_storage_redundancy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'server_create_time': {'key': 'properties.serverCreateTime', 'type': 'iso-8601'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'database_deletion_time': {'key': 'properties.databaseDeletionTime', 'type': 'iso-8601'}, - 'backup_time': {'key': 'properties.backupTime', 'type': 'iso-8601'}, - 'backup_expiration_time': {'key': 'properties.backupExpirationTime', 'type': 'iso-8601'}, - 'backup_storage_redundancy': {'key': 'properties.backupStorageRedundancy', 'type': 'str'}, - 'requested_backup_storage_redundancy': {'key': 'properties.requestedBackupStorageRedundancy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LongTermRetentionBackup, self).__init__(**kwargs) - self.server_name = None - self.server_create_time = None - self.database_name = None - self.database_deletion_time = None - self.backup_time = None - self.backup_expiration_time = None - self.backup_storage_redundancy = None - self.requested_backup_storage_redundancy = kwargs.get('requested_backup_storage_redundancy', None) - - -class LongTermRetentionBackupListResult(msrest.serialization.Model): - """A list of long term retention backups. - - 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.LongTermRetentionBackup] - :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': '[LongTermRetentionBackup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LongTermRetentionBackupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class LongTermRetentionBackupOperationResult(ProxyResource): - """A LongTermRetentionBackup operation result resource. - - 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 request_id: Request Id. - :vartype request_id: str - :ivar operation_type: Operation type. - :vartype operation_type: str - :ivar from_backup_resource_id: Source backup resource id. - :vartype from_backup_resource_id: str - :ivar to_backup_resource_id: Target backup resource id. - :vartype to_backup_resource_id: str - :ivar target_backup_storage_redundancy: The storage redundancy type of the copied backup. - Possible values include: "Geo", "Local", "Zone", "GeoZone". - :vartype target_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar status: Operation status. - :vartype status: str - :ivar message: Progress message. - :vartype message: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'request_id': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'from_backup_resource_id': {'readonly': True}, - 'to_backup_resource_id': {'readonly': True}, - 'target_backup_storage_redundancy': {'readonly': True}, - 'status': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'request_id': {'key': 'properties.requestId', 'type': 'str'}, - 'operation_type': {'key': 'properties.operationType', 'type': 'str'}, - 'from_backup_resource_id': {'key': 'properties.fromBackupResourceId', 'type': 'str'}, - 'to_backup_resource_id': {'key': 'properties.toBackupResourceId', 'type': 'str'}, - 'target_backup_storage_redundancy': {'key': 'properties.targetBackupStorageRedundancy', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'message': {'key': 'properties.message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LongTermRetentionBackupOperationResult, self).__init__(**kwargs) - self.request_id = None - self.operation_type = None - self.from_backup_resource_id = None - self.to_backup_resource_id = None - self.target_backup_storage_redundancy = None - self.status = None - self.message = None - - -class LongTermRetentionPolicy(ProxyResource): - """A long term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :type weekly_retention: str - :param monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. - :type monthly_retention: str - :param yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :type yearly_retention: str - :param week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :type week_of_year: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'weekly_retention': {'key': 'properties.weeklyRetention', 'type': 'str'}, - 'monthly_retention': {'key': 'properties.monthlyRetention', 'type': 'str'}, - 'yearly_retention': {'key': 'properties.yearlyRetention', 'type': 'str'}, - 'week_of_year': {'key': 'properties.weekOfYear', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(LongTermRetentionPolicy, self).__init__(**kwargs) - self.weekly_retention = kwargs.get('weekly_retention', None) - self.monthly_retention = kwargs.get('monthly_retention', None) - self.yearly_retention = kwargs.get('yearly_retention', None) - self.week_of_year = kwargs.get('week_of_year', None) - - -class LongTermRetentionPolicyListResult(msrest.serialization.Model): - """A list of long term retention policies. - - 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.LongTermRetentionPolicy] - :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': '[LongTermRetentionPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LongTermRetentionPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class MaintenanceConfigurationCapability(msrest.serialization.Model): - """The maintenance configuration capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Maintenance configuration name. - :vartype name: str - :ivar zone_redundant: Whether or not zone redundancy is supported for the maintenance - configuration. - :vartype zone_redundant: bool - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'zone_redundant': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MaintenanceConfigurationCapability, self).__init__(**kwargs) - self.name = None - self.zone_redundant = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class MaintenanceWindowOptions(ProxyResource): - """Maintenance window options. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param is_enabled: Whether maintenance windows are enabled for the database. - :type is_enabled: bool - :param maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\ *60}, - {Wednesday, 0, 24*\ 60}. - :type maintenance_window_cycles: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] - :param min_duration_in_minutes: Minimum duration of maintenance window. - :type min_duration_in_minutes: int - :param default_duration_in_minutes: Default duration for maintenance window. - :type default_duration_in_minutes: int - :param min_cycles: Minimum number of maintenance windows cycles to be set on the database. - :type min_cycles: int - :param time_granularity_in_minutes: Time granularity in minutes for maintenance windows. - :type time_granularity_in_minutes: int - :param allow_multiple_maintenance_windows_per_cycle: Whether we allow multiple maintenance - windows per cycle. - :type allow_multiple_maintenance_windows_per_cycle: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'maintenance_window_cycles': {'key': 'properties.maintenanceWindowCycles', 'type': '[MaintenanceWindowTimeRange]'}, - 'min_duration_in_minutes': {'key': 'properties.minDurationInMinutes', 'type': 'int'}, - 'default_duration_in_minutes': {'key': 'properties.defaultDurationInMinutes', 'type': 'int'}, - 'min_cycles': {'key': 'properties.minCycles', 'type': 'int'}, - 'time_granularity_in_minutes': {'key': 'properties.timeGranularityInMinutes', 'type': 'int'}, - 'allow_multiple_maintenance_windows_per_cycle': {'key': 'properties.allowMultipleMaintenanceWindowsPerCycle', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MaintenanceWindowOptions, self).__init__(**kwargs) - self.is_enabled = kwargs.get('is_enabled', None) - self.maintenance_window_cycles = kwargs.get('maintenance_window_cycles', None) - self.min_duration_in_minutes = kwargs.get('min_duration_in_minutes', None) - self.default_duration_in_minutes = kwargs.get('default_duration_in_minutes', None) - self.min_cycles = kwargs.get('min_cycles', None) - self.time_granularity_in_minutes = kwargs.get('time_granularity_in_minutes', None) - self.allow_multiple_maintenance_windows_per_cycle = kwargs.get('allow_multiple_maintenance_windows_per_cycle', None) - - -class MaintenanceWindows(ProxyResource): - """Maintenance windows. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param time_ranges: - :type time_ranges: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'time_ranges': {'key': 'properties.timeRanges', 'type': '[MaintenanceWindowTimeRange]'}, - } - - def __init__( - self, - **kwargs - ): - super(MaintenanceWindows, self).__init__(**kwargs) - self.time_ranges = kwargs.get('time_ranges', None) - - -class MaintenanceWindowTimeRange(msrest.serialization.Model): - """Maintenance window time range. - - :param day_of_week: Day of maintenance window. Possible values include: "Sunday", "Monday", - "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". - :type day_of_week: str or ~azure.mgmt.sql.models.DayOfWeek - :param start_time: Start time minutes offset from 12am. - :type start_time: str - :param duration: Duration of maintenance window in minutes. - :type duration: str - """ - - _attribute_map = { - 'day_of_week': {'key': 'dayOfWeek', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MaintenanceWindowTimeRange, self).__init__(**kwargs) - self.day_of_week = kwargs.get('day_of_week', None) - self.start_time = kwargs.get('start_time', None) - self.duration = kwargs.get('duration', None) - - -class ManagedBackupShortTermRetentionPolicy(ProxyResource): - """A short term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param retention_days: The backup retention period in days. This is how many days Point-in-Time - Restore will be supported. - :type retention_days: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedBackupShortTermRetentionPolicy, self).__init__(**kwargs) - self.retention_days = kwargs.get('retention_days', None) - - -class ManagedBackupShortTermRetentionPolicyListResult(msrest.serialization.Model): - """A list of short term retention policies. - - 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.ManagedBackupShortTermRetentionPolicy] - :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': '[ManagedBackupShortTermRetentionPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedBackupShortTermRetentionPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedDatabase(TrackedResource): - """A managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param collation: Collation of the managed database. - :type collation: str - :ivar status: Status of the database. Possible values include: "Online", "Offline", "Shutdown", - "Creating", "Inaccessible", "Restoring", "Updating". - :vartype status: str or ~azure.mgmt.sql.models.ManagedDatabaseStatus - :ivar creation_date: Creation date of the database. - :vartype creation_date: ~datetime.datetime - :ivar earliest_restore_point: Earliest restore point in time for point in time restore. - :vartype earliest_restore_point: ~datetime.datetime - :param restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is - required. Specifies the point in time (ISO8601 format) of the source database that will be - restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :ivar default_secondary_location: Geo paired region. - :vartype default_secondary_location: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: - "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param create_mode: Managed database create mode. PointInTimeRestore: Create a database by - restoring a point in time backup of an existing database. SourceDatabaseName, - SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a - database by restoring from external backup files. Collation, StorageContainerUri and - StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a - geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database - resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a - long term retention backup (longTermRetentionBackupResourceId required). Possible values - include: "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", - "RestoreLongTermRetentionBackup". - :type create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :param storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value - is required. Specifies the uri of the storage container where backups for this restore are - stored. - :type storage_container_uri: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str - :param restorable_dropped_database_id: The restorable dropped database resource id to restore - when creating this database. - :type restorable_dropped_database_id: str - :param storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this - value is required. Specifies the storage container sas token. - :type storage_container_sas_token: str - :ivar failover_group_id: Instance Failover Group resource identifier that this managed database - belongs to. - :vartype failover_group_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :type recoverable_database_id: str - :param long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be - used for restore of this managed database. - :type long_term_retention_backup_resource_id: str - :param auto_complete_restore: Whether to auto complete restore of this managed database. - :type auto_complete_restore: bool - :param last_backup_name: Last backup file name for restore of this managed database. - :type last_backup_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'status': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'earliest_restore_point': {'readonly': True}, - 'default_secondary_location': {'readonly': True}, - 'failover_group_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'earliest_restore_point': {'key': 'properties.earliestRestorePoint', 'type': 'iso-8601'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'default_secondary_location': {'key': 'properties.defaultSecondaryLocation', 'type': 'str'}, - 'catalog_collation': {'key': 'properties.catalogCollation', 'type': 'str'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'storage_container_uri': {'key': 'properties.storageContainerUri', 'type': 'str'}, - 'source_database_id': {'key': 'properties.sourceDatabaseId', 'type': 'str'}, - 'restorable_dropped_database_id': {'key': 'properties.restorableDroppedDatabaseId', 'type': 'str'}, - 'storage_container_sas_token': {'key': 'properties.storageContainerSasToken', 'type': 'str'}, - 'failover_group_id': {'key': 'properties.failoverGroupId', 'type': 'str'}, - 'recoverable_database_id': {'key': 'properties.recoverableDatabaseId', 'type': 'str'}, - 'long_term_retention_backup_resource_id': {'key': 'properties.longTermRetentionBackupResourceId', 'type': 'str'}, - 'auto_complete_restore': {'key': 'properties.autoCompleteRestore', 'type': 'bool'}, - 'last_backup_name': {'key': 'properties.lastBackupName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedDatabase, self).__init__(**kwargs) - self.collation = kwargs.get('collation', None) - self.status = None - self.creation_date = None - self.earliest_restore_point = None - self.restore_point_in_time = kwargs.get('restore_point_in_time', None) - self.default_secondary_location = None - self.catalog_collation = kwargs.get('catalog_collation', None) - self.create_mode = kwargs.get('create_mode', None) - self.storage_container_uri = kwargs.get('storage_container_uri', None) - self.source_database_id = kwargs.get('source_database_id', None) - self.restorable_dropped_database_id = kwargs.get('restorable_dropped_database_id', None) - self.storage_container_sas_token = kwargs.get('storage_container_sas_token', None) - self.failover_group_id = None - self.recoverable_database_id = kwargs.get('recoverable_database_id', None) - self.long_term_retention_backup_resource_id = kwargs.get('long_term_retention_backup_resource_id', None) - self.auto_complete_restore = kwargs.get('auto_complete_restore', None) - self.last_backup_name = kwargs.get('last_backup_name', None) - - -class ManagedDatabaseListResult(msrest.serialization.Model): - """A list of managed databases. - - 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.ManagedDatabase] - :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': '[ManagedDatabase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedDatabaseListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedDatabaseRestoreDetailsResult(ProxyResource): - """A managed database restore details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar status: Restore status. - :vartype status: str - :ivar current_restoring_file_name: Current restoring file name. - :vartype current_restoring_file_name: str - :ivar last_restored_file_name: Last restored file name. - :vartype last_restored_file_name: str - :ivar last_restored_file_time: Last restored file time. - :vartype last_restored_file_time: ~datetime.datetime - :ivar percent_completed: Percent completed. - :vartype percent_completed: float - :ivar unrestorable_files: List of unrestorable files. - :vartype unrestorable_files: list[str] - :ivar number_of_files_detected: Number of files detected. - :vartype number_of_files_detected: long - :ivar last_uploaded_file_name: Last uploaded file name. - :vartype last_uploaded_file_name: str - :ivar last_uploaded_file_time: Last uploaded file time. - :vartype last_uploaded_file_time: ~datetime.datetime - :ivar block_reason: The reason why restore is in Blocked state. - :vartype block_reason: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'current_restoring_file_name': {'readonly': True}, - 'last_restored_file_name': {'readonly': True}, - 'last_restored_file_time': {'readonly': True}, - 'percent_completed': {'readonly': True}, - 'unrestorable_files': {'readonly': True}, - 'number_of_files_detected': {'readonly': True}, - 'last_uploaded_file_name': {'readonly': True}, - 'last_uploaded_file_time': {'readonly': True}, - 'block_reason': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'current_restoring_file_name': {'key': 'properties.currentRestoringFileName', 'type': 'str'}, - 'last_restored_file_name': {'key': 'properties.lastRestoredFileName', 'type': 'str'}, - 'last_restored_file_time': {'key': 'properties.lastRestoredFileTime', 'type': 'iso-8601'}, - 'percent_completed': {'key': 'properties.percentCompleted', 'type': 'float'}, - 'unrestorable_files': {'key': 'properties.unrestorableFiles', 'type': '[str]'}, - 'number_of_files_detected': {'key': 'properties.numberOfFilesDetected', 'type': 'long'}, - 'last_uploaded_file_name': {'key': 'properties.lastUploadedFileName', 'type': 'str'}, - 'last_uploaded_file_time': {'key': 'properties.lastUploadedFileTime', 'type': 'iso-8601'}, - 'block_reason': {'key': 'properties.blockReason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedDatabaseRestoreDetailsResult, self).__init__(**kwargs) - self.status = None - self.current_restoring_file_name = None - self.last_restored_file_name = None - self.last_restored_file_time = None - self.percent_completed = None - self.unrestorable_files = None - self.number_of_files_detected = None - self.last_uploaded_file_name = None - self.last_uploaded_file_time = None - self.block_reason = None - - -class ManagedDatabaseSecurityAlertPolicy(ProxyResource): - """A managed database security alert policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Possible values include: "New", "Enabled", - "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int - :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}, - 'creation_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedDatabaseSecurityAlertPolicy, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - self.disabled_alerts = kwargs.get('disabled_alerts', None) - self.email_addresses = kwargs.get('email_addresses', None) - self.email_account_admins = kwargs.get('email_account_admins', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.retention_days = kwargs.get('retention_days', None) - self.creation_time = None - - -class ManagedDatabaseSecurityAlertPolicyListResult(msrest.serialization.Model): - """A list of the managed database's security alert policies. - - 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.ManagedDatabaseSecurityAlertPolicy] - :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': '[ManagedDatabaseSecurityAlertPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedDatabaseSecurityAlertPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedDatabaseUpdate(msrest.serialization.Model): - """An managed database update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param collation: Collation of the managed database. - :type collation: str - :ivar status: Status of the database. Possible values include: "Online", "Offline", "Shutdown", - "Creating", "Inaccessible", "Restoring", "Updating". - :vartype status: str or ~azure.mgmt.sql.models.ManagedDatabaseStatus - :ivar creation_date: Creation date of the database. - :vartype creation_date: ~datetime.datetime - :ivar earliest_restore_point: Earliest restore point in time for point in time restore. - :vartype earliest_restore_point: ~datetime.datetime - :param restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is - required. Specifies the point in time (ISO8601 format) of the source database that will be - restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :ivar default_secondary_location: Geo paired region. - :vartype default_secondary_location: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: - "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param create_mode: Managed database create mode. PointInTimeRestore: Create a database by - restoring a point in time backup of an existing database. SourceDatabaseName, - SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a - database by restoring from external backup files. Collation, StorageContainerUri and - StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a - geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database - resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a - long term retention backup (longTermRetentionBackupResourceId required). Possible values - include: "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", - "RestoreLongTermRetentionBackup". - :type create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :param storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value - is required. Specifies the uri of the storage container where backups for this restore are - stored. - :type storage_container_uri: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str - :param restorable_dropped_database_id: The restorable dropped database resource id to restore - when creating this database. - :type restorable_dropped_database_id: str - :param storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this - value is required. Specifies the storage container sas token. - :type storage_container_sas_token: str - :ivar failover_group_id: Instance Failover Group resource identifier that this managed database - belongs to. - :vartype failover_group_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :type recoverable_database_id: str - :param long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be - used for restore of this managed database. - :type long_term_retention_backup_resource_id: str - :param auto_complete_restore: Whether to auto complete restore of this managed database. - :type auto_complete_restore: bool - :param last_backup_name: Last backup file name for restore of this managed database. - :type last_backup_name: str - """ - - _validation = { - 'status': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'earliest_restore_point': {'readonly': True}, - 'default_secondary_location': {'readonly': True}, - 'failover_group_id': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'earliest_restore_point': {'key': 'properties.earliestRestorePoint', 'type': 'iso-8601'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'default_secondary_location': {'key': 'properties.defaultSecondaryLocation', 'type': 'str'}, - 'catalog_collation': {'key': 'properties.catalogCollation', 'type': 'str'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'storage_container_uri': {'key': 'properties.storageContainerUri', 'type': 'str'}, - 'source_database_id': {'key': 'properties.sourceDatabaseId', 'type': 'str'}, - 'restorable_dropped_database_id': {'key': 'properties.restorableDroppedDatabaseId', 'type': 'str'}, - 'storage_container_sas_token': {'key': 'properties.storageContainerSasToken', 'type': 'str'}, - 'failover_group_id': {'key': 'properties.failoverGroupId', 'type': 'str'}, - 'recoverable_database_id': {'key': 'properties.recoverableDatabaseId', 'type': 'str'}, - 'long_term_retention_backup_resource_id': {'key': 'properties.longTermRetentionBackupResourceId', 'type': 'str'}, - 'auto_complete_restore': {'key': 'properties.autoCompleteRestore', 'type': 'bool'}, - 'last_backup_name': {'key': 'properties.lastBackupName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedDatabaseUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.collation = kwargs.get('collation', None) - self.status = None - self.creation_date = None - self.earliest_restore_point = None - self.restore_point_in_time = kwargs.get('restore_point_in_time', None) - self.default_secondary_location = None - self.catalog_collation = kwargs.get('catalog_collation', None) - self.create_mode = kwargs.get('create_mode', None) - self.storage_container_uri = kwargs.get('storage_container_uri', None) - self.source_database_id = kwargs.get('source_database_id', None) - self.restorable_dropped_database_id = kwargs.get('restorable_dropped_database_id', None) - self.storage_container_sas_token = kwargs.get('storage_container_sas_token', None) - self.failover_group_id = None - self.recoverable_database_id = kwargs.get('recoverable_database_id', None) - self.long_term_retention_backup_resource_id = kwargs.get('long_term_retention_backup_resource_id', None) - self.auto_complete_restore = kwargs.get('auto_complete_restore', None) - self.last_backup_name = kwargs.get('last_backup_name', None) - - -class ManagedInstance(TrackedResource): - """An Azure SQL managed instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: The Azure Active Directory identity of the managed instance. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity - :param sku: Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, - BC_Gen5. - :type sku: ~azure.mgmt.sql.models.Sku - :ivar provisioning_state: Possible values include: "Creating", "Deleting", "Updating", - "Unknown", "Succeeded", "Failed", "Accepted", "Created", "Deleted", "Unrecognized", "Running", - "Canceled", "NotSpecified", "Registering", "TimedOut". - :vartype provisioning_state: str or - ~azure.mgmt.sql.models.ManagedInstancePropertiesProvisioningState - :param managed_instance_create_mode: Specifies the mode of database creation. - - Default: Regular instance creation. - - Restore: Creates an instance by restoring a set of backups to specific point in time. - RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: - "Default", "PointInTimeRestore". - :type managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode - :ivar fully_qualified_domain_name: The fully qualified domain name of the managed instance. - :vartype fully_qualified_domain_name: str - :param administrator_login: Administrator username for the managed instance. Can only be - specified when the managed instance is being created (and is required for creation). - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for managed - instance creation). - :type administrator_login_password: str - :param subnet_id: Subnet resource ID for the managed instance. - :type subnet_id: str - :ivar state: The state of the managed instance. - :vartype state: str - :param license_type: The license type. Possible values are 'LicenseIncluded' (regular price - inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL - licenses). Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType - :param v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. - :type v_cores: int - :param storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. - Increments of 32 GB allowed only. - :type storage_size_in_gb: int - :param collation: Collation of the managed instance. - :type collation: str - :ivar dns_zone: The Dns Zone that the managed instance is in. - :vartype dns_zone: str - :param dns_zone_partner: The resource id of another managed instance whose DNS zone this - managed instance will share after creation. - :type dns_zone_partner: str - :param public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :type public_data_endpoint_enabled: bool - :param source_managed_instance_id: The resource identifier of the source managed instance - associated with create operation of this instance. - :type source_managed_instance_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param proxy_override: Connection type used for connecting to the instance. Possible values - include: "Proxy", "Redirect", "Default". - :type proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :param timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. - Windows keeps details on supported timezones, including the id, in registry under - KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. - You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM - sys.time_zone_info. - List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in - PowerShell. - An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :type timezone_id: str - :param instance_pool_id: The Id of the instance pool this managed server belongs to. - :type instance_pool_id: str - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :type maintenance_configuration_id: str - :ivar private_endpoint_connections: List of private endpoint connections on a managed instance. - :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ManagedInstancePecProperty] - :param minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :type minimal_tls_version: str - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), - Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: "Geo", - "Local", "Zone", "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this instance. The options are Local (LocallyRedundantStorage), Zone - (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). - Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param zone_redundant: Whether or not the multi-az is enabled. - :type zone_redundant: bool - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory administrator of the server. - :type administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :param service_principal: The managed instance's service principal. - :type service_principal: ~azure.mgmt.sql.models.ServicePrincipal - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'fully_qualified_domain_name': {'readonly': True}, - 'state': {'readonly': True}, - 'dns_zone': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'current_backup_storage_redundancy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'managed_instance_create_mode': {'key': 'properties.managedInstanceCreateMode', 'type': 'str'}, - 'fully_qualified_domain_name': {'key': 'properties.fullyQualifiedDomainName', 'type': 'str'}, - 'administrator_login': {'key': 'properties.administratorLogin', 'type': 'str'}, - 'administrator_login_password': {'key': 'properties.administratorLoginPassword', 'type': 'str'}, - 'subnet_id': {'key': 'properties.subnetId', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'license_type': {'key': 'properties.licenseType', 'type': 'str'}, - 'v_cores': {'key': 'properties.vCores', 'type': 'int'}, - 'storage_size_in_gb': {'key': 'properties.storageSizeInGB', 'type': 'int'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'dns_zone': {'key': 'properties.dnsZone', 'type': 'str'}, - 'dns_zone_partner': {'key': 'properties.dnsZonePartner', 'type': 'str'}, - 'public_data_endpoint_enabled': {'key': 'properties.publicDataEndpointEnabled', 'type': 'bool'}, - 'source_managed_instance_id': {'key': 'properties.sourceManagedInstanceId', 'type': 'str'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'proxy_override': {'key': 'properties.proxyOverride', 'type': 'str'}, - 'timezone_id': {'key': 'properties.timezoneId', 'type': 'str'}, - 'instance_pool_id': {'key': 'properties.instancePoolId', 'type': 'str'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[ManagedInstancePecProperty]'}, - 'minimal_tls_version': {'key': 'properties.minimalTlsVersion', 'type': 'str'}, - 'current_backup_storage_redundancy': {'key': 'properties.currentBackupStorageRedundancy', 'type': 'str'}, - 'requested_backup_storage_redundancy': {'key': 'properties.requestedBackupStorageRedundancy', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'primary_user_assigned_identity_id': {'key': 'properties.primaryUserAssignedIdentityId', 'type': 'str'}, - 'key_id': {'key': 'properties.keyId', 'type': 'str'}, - 'administrators': {'key': 'properties.administrators', 'type': 'ManagedInstanceExternalAdministrator'}, - 'service_principal': {'key': 'properties.servicePrincipal', 'type': 'ServicePrincipal'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstance, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.sku = kwargs.get('sku', None) - self.provisioning_state = None - self.managed_instance_create_mode = kwargs.get('managed_instance_create_mode', None) - self.fully_qualified_domain_name = None - self.administrator_login = kwargs.get('administrator_login', None) - self.administrator_login_password = kwargs.get('administrator_login_password', None) - self.subnet_id = kwargs.get('subnet_id', None) - self.state = None - self.license_type = kwargs.get('license_type', None) - self.v_cores = kwargs.get('v_cores', None) - self.storage_size_in_gb = kwargs.get('storage_size_in_gb', None) - self.collation = kwargs.get('collation', None) - self.dns_zone = None - self.dns_zone_partner = kwargs.get('dns_zone_partner', None) - self.public_data_endpoint_enabled = kwargs.get('public_data_endpoint_enabled', None) - self.source_managed_instance_id = kwargs.get('source_managed_instance_id', None) - self.restore_point_in_time = kwargs.get('restore_point_in_time', None) - self.proxy_override = kwargs.get('proxy_override', None) - self.timezone_id = kwargs.get('timezone_id', None) - self.instance_pool_id = kwargs.get('instance_pool_id', None) - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - self.private_endpoint_connections = None - self.minimal_tls_version = kwargs.get('minimal_tls_version', None) - self.current_backup_storage_redundancy = None - self.requested_backup_storage_redundancy = kwargs.get('requested_backup_storage_redundancy', None) - self.zone_redundant = kwargs.get('zone_redundant', None) - self.primary_user_assigned_identity_id = kwargs.get('primary_user_assigned_identity_id', None) - self.key_id = kwargs.get('key_id', None) - self.administrators = kwargs.get('administrators', None) - self.service_principal = kwargs.get('service_principal', None) - - -class ManagedInstanceAdministrator(ProxyResource): - """An Azure SQL managed instance administrator. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param administrator_type: Type of the managed instance administrator. Possible values include: - "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.ManagedInstanceAdministratorType - :param login: Login name of the managed instance administrator. - :type login: str - :param sid: SID (object ID) of the managed instance administrator. - :type sid: str - :param tenant_id: Tenant ID of the managed instance administrator. - :type tenant_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'administrator_type': {'key': 'properties.administratorType', 'type': 'str'}, - 'login': {'key': 'properties.login', 'type': 'str'}, - 'sid': {'key': 'properties.sid', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceAdministrator, self).__init__(**kwargs) - self.administrator_type = kwargs.get('administrator_type', None) - self.login = kwargs.get('login', None) - self.sid = kwargs.get('sid', None) - self.tenant_id = kwargs.get('tenant_id', None) - - -class ManagedInstanceAdministratorListResult(msrest.serialization.Model): - """A list of managed instance administrators. - - 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.ManagedInstanceAdministrator] - :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': '[ManagedInstanceAdministrator]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceAdministratorListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceAzureADOnlyAuthentication(ProxyResource): - """Azure Active Directory only authentication. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'azure_ad_only_authentication': {'key': 'properties.azureADOnlyAuthentication', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceAzureADOnlyAuthentication, self).__init__(**kwargs) - self.azure_ad_only_authentication = kwargs.get('azure_ad_only_authentication', None) - - -class ManagedInstanceAzureADOnlyAuthListResult(msrest.serialization.Model): - """A list of active directory only authentications. - - 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.ManagedInstanceAzureADOnlyAuthentication] - :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': '[ManagedInstanceAzureADOnlyAuthentication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceAzureADOnlyAuthListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceEditionCapability(msrest.serialization.Model): - """The managed server capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The managed server version name. - :vartype name: str - :ivar supported_families: The supported families. - :vartype supported_families: list[~azure.mgmt.sql.models.ManagedInstanceFamilyCapability] - :ivar supported_storage_capabilities: The list of supported storage capabilities for this - edition. - :vartype supported_storage_capabilities: list[~azure.mgmt.sql.models.StorageCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the edition. - :vartype zone_redundant: bool - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_families': {'readonly': True}, - 'supported_storage_capabilities': {'readonly': True}, - 'zone_redundant': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_families': {'key': 'supportedFamilies', 'type': '[ManagedInstanceFamilyCapability]'}, - 'supported_storage_capabilities': {'key': 'supportedStorageCapabilities', 'type': '[StorageCapability]'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceEditionCapability, self).__init__(**kwargs) - self.name = None - self.supported_families = None - self.supported_storage_capabilities = None - self.zone_redundant = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ManagedInstanceEncryptionProtector(ProxyResource): - """The managed instance encryption protector. - - 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 kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :param server_key_name: The name of the managed instance key. - :type server_key_name: str - :param server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Possible values include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :ivar uri: The URI of the server key. - :vartype uri: str - :ivar thumbprint: Thumbprint of the server key. - :vartype thumbprint: str - :param auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :type auto_rotation_enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'uri': {'readonly': True}, - 'thumbprint': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'server_key_name': {'key': 'properties.serverKeyName', 'type': 'str'}, - 'server_key_type': {'key': 'properties.serverKeyType', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'auto_rotation_enabled': {'key': 'properties.autoRotationEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceEncryptionProtector, self).__init__(**kwargs) - self.kind = None - self.server_key_name = kwargs.get('server_key_name', None) - self.server_key_type = kwargs.get('server_key_type', None) - self.uri = None - self.thumbprint = None - self.auto_rotation_enabled = kwargs.get('auto_rotation_enabled', None) - - -class ManagedInstanceEncryptionProtectorListResult(msrest.serialization.Model): - """A list of managed instance encryption protectors. - - 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.ManagedInstanceEncryptionProtector] - :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': '[ManagedInstanceEncryptionProtector]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceEncryptionProtectorListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceExternalAdministrator(msrest.serialization.Model): - """Properties of a active directory administrator. - - :param administrator_type: Type of the sever administrator. Possible values include: - "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :param principal_type: Principal Type of the sever administrator. Possible values include: - "User", "Group", "Application". - :type principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :param login: Login name of the server administrator. - :type login: str - :param sid: SID (object ID) of the server administrator. - :type sid: str - :param tenant_id: Tenant ID of the administrator. - :type tenant_id: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool - """ - - _attribute_map = { - 'administrator_type': {'key': 'administratorType', 'type': 'str'}, - 'principal_type': {'key': 'principalType', 'type': 'str'}, - 'login': {'key': 'login', 'type': 'str'}, - 'sid': {'key': 'sid', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'azure_ad_only_authentication': {'key': 'azureADOnlyAuthentication', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceExternalAdministrator, self).__init__(**kwargs) - self.administrator_type = kwargs.get('administrator_type', None) - self.principal_type = kwargs.get('principal_type', None) - self.login = kwargs.get('login', None) - self.sid = kwargs.get('sid', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.azure_ad_only_authentication = kwargs.get('azure_ad_only_authentication', None) - - -class ManagedInstanceFamilyCapability(msrest.serialization.Model): - """The managed server family capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Family name. - :vartype name: str - :ivar sku: SKU name. - :vartype sku: str - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar supported_vcores_values: List of supported virtual cores values. - :vartype supported_vcores_values: list[~azure.mgmt.sql.models.ManagedInstanceVcoresCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'sku': {'readonly': True}, - 'supported_license_types': {'readonly': True}, - 'supported_vcores_values': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'supported_license_types': {'key': 'supportedLicenseTypes', 'type': '[LicenseTypeCapability]'}, - 'supported_vcores_values': {'key': 'supportedVcoresValues', 'type': '[ManagedInstanceVcoresCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceFamilyCapability, self).__init__(**kwargs) - self.name = None - self.sku = None - self.supported_license_types = None - self.supported_vcores_values = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ManagedInstanceKey(ProxyResource): - """A managed instance key. - - 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 kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :param server_key_type: The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values - include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :param uri: The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is - required. - :type uri: str - :ivar thumbprint: Thumbprint of the key. - :vartype thumbprint: str - :ivar creation_date: The key creation date. - :vartype creation_date: ~datetime.datetime - :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :vartype auto_rotation_enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'auto_rotation_enabled': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'server_key_type': {'key': 'properties.serverKeyType', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'auto_rotation_enabled': {'key': 'properties.autoRotationEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceKey, self).__init__(**kwargs) - self.kind = None - self.server_key_type = kwargs.get('server_key_type', None) - self.uri = kwargs.get('uri', None) - self.thumbprint = None - self.creation_date = None - self.auto_rotation_enabled = None - - -class ManagedInstanceKeyListResult(msrest.serialization.Model): - """A list of managed instance keys. - - 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.ManagedInstanceKey] - :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': '[ManagedInstanceKey]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceKeyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceListResult(msrest.serialization.Model): - """A list of managed instances. - - 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.ManagedInstance] - :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': '[ManagedInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceLongTermRetentionBackup(ProxyResource): - """A long term retention backup for a managed database. - - 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 managed_instance_name: The managed instance that the backup database belongs to. - :vartype managed_instance_name: str - :ivar managed_instance_create_time: The create time of the instance. - :vartype managed_instance_create_time: ~datetime.datetime - :ivar database_name: The name of the database the backup belong to. - :vartype database_name: str - :ivar database_deletion_time: The delete time of the database. - :vartype database_deletion_time: ~datetime.datetime - :ivar backup_time: The time the backup was taken. - :vartype backup_time: ~datetime.datetime - :ivar backup_expiration_time: The time the long term retention backup will expire. - :vartype backup_expiration_time: ~datetime.datetime - :ivar backup_storage_redundancy: The storage redundancy type of the backup. Possible values - include: "Geo", "Local", "Zone", "GeoZone". - :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'managed_instance_name': {'readonly': True}, - 'managed_instance_create_time': {'readonly': True}, - 'database_name': {'readonly': True}, - 'database_deletion_time': {'readonly': True}, - 'backup_time': {'readonly': True}, - 'backup_expiration_time': {'readonly': True}, - 'backup_storage_redundancy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'managed_instance_name': {'key': 'properties.managedInstanceName', 'type': 'str'}, - 'managed_instance_create_time': {'key': 'properties.managedInstanceCreateTime', 'type': 'iso-8601'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'database_deletion_time': {'key': 'properties.databaseDeletionTime', 'type': 'iso-8601'}, - 'backup_time': {'key': 'properties.backupTime', 'type': 'iso-8601'}, - 'backup_expiration_time': {'key': 'properties.backupExpirationTime', 'type': 'iso-8601'}, - 'backup_storage_redundancy': {'key': 'properties.backupStorageRedundancy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceLongTermRetentionBackup, self).__init__(**kwargs) - self.managed_instance_name = None - self.managed_instance_create_time = None - self.database_name = None - self.database_deletion_time = None - self.backup_time = None - self.backup_expiration_time = None - self.backup_storage_redundancy = None - - -class ManagedInstanceLongTermRetentionBackupListResult(msrest.serialization.Model): - """A list of long term retention backups for managed database(s). - - 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.ManagedInstanceLongTermRetentionBackup] - :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': '[ManagedInstanceLongTermRetentionBackup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceLongTermRetentionBackupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceLongTermRetentionPolicy(ProxyResource): - """A long term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :type weekly_retention: str - :param monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. - :type monthly_retention: str - :param yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :type yearly_retention: str - :param week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :type week_of_year: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'weekly_retention': {'key': 'properties.weeklyRetention', 'type': 'str'}, - 'monthly_retention': {'key': 'properties.monthlyRetention', 'type': 'str'}, - 'yearly_retention': {'key': 'properties.yearlyRetention', 'type': 'str'}, - 'week_of_year': {'key': 'properties.weekOfYear', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceLongTermRetentionPolicy, self).__init__(**kwargs) - self.weekly_retention = kwargs.get('weekly_retention', None) - self.monthly_retention = kwargs.get('monthly_retention', None) - self.yearly_retention = kwargs.get('yearly_retention', None) - self.week_of_year = kwargs.get('week_of_year', None) - - -class ManagedInstanceLongTermRetentionPolicyListResult(msrest.serialization.Model): - """A list of long term retention policies. - - 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.ManagedInstanceLongTermRetentionPolicy] - :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': '[ManagedInstanceLongTermRetentionPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceLongTermRetentionPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceMaintenanceConfigurationCapability(msrest.serialization.Model): - """The maintenance configuration capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Maintenance configuration name. - :vartype name: str - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceMaintenanceConfigurationCapability, self).__init__(**kwargs) - self.name = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ManagedInstanceOperation(ProxyResource): - """A managed instance operation. - - 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 managed_instance_name: The name of the managed instance the operation is being performed - on. - :vartype managed_instance_name: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Possible values include: "Pending", "InProgress", - "Succeeded", "Failed", "CancelInProgress", "Cancelled". - :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - :ivar operation_parameters: The operation parameters. - :vartype operation_parameters: ~azure.mgmt.sql.models.ManagedInstanceOperationParametersPair - :ivar operation_steps: The operation steps. - :vartype operation_steps: ~azure.mgmt.sql.models.ManagedInstanceOperationSteps - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'managed_instance_name': {'readonly': True}, - 'operation': {'readonly': True}, - 'operation_friendly_name': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'start_time': {'readonly': True}, - 'state': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_description': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'is_user_error': {'readonly': True}, - 'estimated_completion_time': {'readonly': True}, - 'description': {'readonly': True}, - 'is_cancellable': {'readonly': True}, - 'operation_parameters': {'readonly': True}, - 'operation_steps': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'managed_instance_name': {'key': 'properties.managedInstanceName', 'type': 'str'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'operation_friendly_name': {'key': 'properties.operationFriendlyName', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, - 'error_description': {'key': 'properties.errorDescription', 'type': 'str'}, - 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, - 'is_user_error': {'key': 'properties.isUserError', 'type': 'bool'}, - 'estimated_completion_time': {'key': 'properties.estimatedCompletionTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_cancellable': {'key': 'properties.isCancellable', 'type': 'bool'}, - 'operation_parameters': {'key': 'properties.operationParameters', 'type': 'ManagedInstanceOperationParametersPair'}, - 'operation_steps': {'key': 'properties.operationSteps', 'type': 'ManagedInstanceOperationSteps'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceOperation, self).__init__(**kwargs) - self.managed_instance_name = None - self.operation = None - self.operation_friendly_name = None - self.percent_complete = None - self.start_time = None - self.state = None - self.error_code = None - self.error_description = None - self.error_severity = None - self.is_user_error = None - self.estimated_completion_time = None - self.description = None - self.is_cancellable = None - self.operation_parameters = None - self.operation_steps = None - - -class ManagedInstanceOperationListResult(msrest.serialization.Model): - """The response to a list managed instance operations request. - - 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.ManagedInstanceOperation] - :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': '[ManagedInstanceOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceOperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceOperationParametersPair(msrest.serialization.Model): - """The parameters of a managed instance operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar current_parameters: The current parameters. - :vartype current_parameters: ~azure.mgmt.sql.models.UpsertManagedServerOperationParameters - :ivar requested_parameters: The requested parameters. - :vartype requested_parameters: ~azure.mgmt.sql.models.UpsertManagedServerOperationParameters - """ - - _validation = { - 'current_parameters': {'readonly': True}, - 'requested_parameters': {'readonly': True}, - } - - _attribute_map = { - 'current_parameters': {'key': 'currentParameters', 'type': 'UpsertManagedServerOperationParameters'}, - 'requested_parameters': {'key': 'requestedParameters', 'type': 'UpsertManagedServerOperationParameters'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceOperationParametersPair, self).__init__(**kwargs) - self.current_parameters = None - self.requested_parameters = None - - -class ManagedInstanceOperationSteps(msrest.serialization.Model): - """The steps of a managed instance operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar total_steps: The total number of operation steps. - :vartype total_steps: str - :ivar current_step: The number of current operation steps. - :vartype current_step: int - :ivar steps_list: The operation steps list. - :vartype steps_list: list[~azure.mgmt.sql.models.UpsertManagedServerOperationStep] - """ - - _validation = { - 'total_steps': {'readonly': True}, - 'current_step': {'readonly': True}, - 'steps_list': {'readonly': True}, - } - - _attribute_map = { - 'total_steps': {'key': 'totalSteps', 'type': 'str'}, - 'current_step': {'key': 'currentStep', 'type': 'int'}, - 'steps_list': {'key': 'stepsList', 'type': '[UpsertManagedServerOperationStep]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceOperationSteps, self).__init__(**kwargs) - self.total_steps = None - self.current_step = None - self.steps_list = None - - -class ManagedInstancePairInfo(msrest.serialization.Model): - """Pairs of Managed Instances in the failover group. - - :param primary_managed_instance_id: Id of Primary Managed Instance in pair. - :type primary_managed_instance_id: str - :param partner_managed_instance_id: Id of Partner Managed Instance in pair. - :type partner_managed_instance_id: str - """ - - _attribute_map = { - 'primary_managed_instance_id': {'key': 'primaryManagedInstanceId', 'type': 'str'}, - 'partner_managed_instance_id': {'key': 'partnerManagedInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePairInfo, self).__init__(**kwargs) - self.primary_managed_instance_id = kwargs.get('primary_managed_instance_id', None) - self.partner_managed_instance_id = kwargs.get('partner_managed_instance_id', None) - - -class ManagedInstancePecProperty(msrest.serialization.Model): - """A private endpoint connection under a managed instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar properties: Private endpoint connection properties. - :vartype properties: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ManagedInstancePrivateEndpointConnectionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePecProperty, self).__init__(**kwargs) - self.id = None - self.properties = None - - -class ManagedInstancePrivateEndpointConnection(ProxyResource): - """A private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :param private_link_service_connection_state: Connection State of the Private Endpoint - Connection. - :type private_link_service_connection_state: - ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the Private Endpoint Connection. - :vartype provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'ManagedInstancePrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ManagedInstancePrivateLinkServiceConnectionStateProperty'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateEndpointConnection, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = None - - -class ManagedInstancePrivateEndpointConnectionListResult(msrest.serialization.Model): - """A list of private endpoint connections. - - 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.ManagedInstancePrivateEndpointConnection] - :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': '[ManagedInstancePrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstancePrivateEndpointConnectionProperties(msrest.serialization.Model): - """Properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :param private_link_service_connection_state: Connection State of the Private Endpoint - Connection. - :type private_link_service_connection_state: - ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the Private Endpoint Connection. - :vartype provisioning_state: str - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'ManagedInstancePrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'ManagedInstancePrivateLinkServiceConnectionStateProperty'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = None - - -class ManagedInstancePrivateEndpointProperty(msrest.serialization.Model): - """ManagedInstancePrivateEndpointProperty. - - :param id: Resource id of the private endpoint. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateEndpointProperty, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class ManagedInstancePrivateLink(ProxyResource): - """A private link resource. - - 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 properties: The private link resource group id. - :vartype properties: ~azure.mgmt.sql.models.ManagedInstancePrivateLinkProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ManagedInstancePrivateLinkProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateLink, self).__init__(**kwargs) - self.properties = None - - -class ManagedInstancePrivateLinkListResult(msrest.serialization.Model): - """A list of private link resources. - - 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.ManagedInstancePrivateLink] - :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': '[ManagedInstancePrivateLink]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateLinkListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstancePrivateLinkProperties(msrest.serialization.Model): - """Properties of a private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - """ - - _validation = { - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - } - - _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateLinkProperties, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - - -class ManagedInstancePrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): - """ManagedInstancePrivateLinkServiceConnectionStateProperty. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The private link service connection status. - :type status: str - :param description: Required. The private link service connection description. - :type description: str - :ivar actions_required: The private link service connection description. - :vartype actions_required: str - """ - - _validation = { - 'status': {'required': True}, - 'description': {'required': True}, - 'actions_required': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstancePrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs['description'] - self.actions_required = None - - -class ManagedInstanceQuery(ProxyResource): - """Database query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param query_text: Query text. - :type query_text: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'query_text': {'key': 'properties.queryText', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceQuery, self).__init__(**kwargs) - self.query_text = kwargs.get('query_text', None) - - -class ManagedInstanceQueryStatistics(msrest.serialization.Model): - """Execution statistics for one particular query. - - 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.QueryStatistics] - :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': '[QueryStatistics]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceQueryStatistics, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedInstanceUpdate(msrest.serialization.Model): - """An update request for an Azure SQL Database managed instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param sku: Managed instance sku. - :type sku: ~azure.mgmt.sql.models.Sku - :param identity: Managed instance identity. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar provisioning_state: Possible values include: "Creating", "Deleting", "Updating", - "Unknown", "Succeeded", "Failed", "Accepted", "Created", "Deleted", "Unrecognized", "Running", - "Canceled", "NotSpecified", "Registering", "TimedOut". - :vartype provisioning_state: str or - ~azure.mgmt.sql.models.ManagedInstancePropertiesProvisioningState - :param managed_instance_create_mode: Specifies the mode of database creation. - - Default: Regular instance creation. - - Restore: Creates an instance by restoring a set of backups to specific point in time. - RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: - "Default", "PointInTimeRestore". - :type managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode - :ivar fully_qualified_domain_name: The fully qualified domain name of the managed instance. - :vartype fully_qualified_domain_name: str - :param administrator_login: Administrator username for the managed instance. Can only be - specified when the managed instance is being created (and is required for creation). - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for managed - instance creation). - :type administrator_login_password: str - :param subnet_id: Subnet resource ID for the managed instance. - :type subnet_id: str - :ivar state: The state of the managed instance. - :vartype state: str - :param license_type: The license type. Possible values are 'LicenseIncluded' (regular price - inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL - licenses). Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType - :param v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. - :type v_cores: int - :param storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. - Increments of 32 GB allowed only. - :type storage_size_in_gb: int - :param collation: Collation of the managed instance. - :type collation: str - :ivar dns_zone: The Dns Zone that the managed instance is in. - :vartype dns_zone: str - :param dns_zone_partner: The resource id of another managed instance whose DNS zone this - managed instance will share after creation. - :type dns_zone_partner: str - :param public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :type public_data_endpoint_enabled: bool - :param source_managed_instance_id: The resource identifier of the source managed instance - associated with create operation of this instance. - :type source_managed_instance_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param proxy_override: Connection type used for connecting to the instance. Possible values - include: "Proxy", "Redirect", "Default". - :type proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :param timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. - Windows keeps details on supported timezones, including the id, in registry under - KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. - You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM - sys.time_zone_info. - List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in - PowerShell. - An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :type timezone_id: str - :param instance_pool_id: The Id of the instance pool this managed server belongs to. - :type instance_pool_id: str - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :type maintenance_configuration_id: str - :ivar private_endpoint_connections: List of private endpoint connections on a managed instance. - :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ManagedInstancePecProperty] - :param minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :type minimal_tls_version: str - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), - Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: "Geo", - "Local", "Zone", "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this instance. The options are Local (LocallyRedundantStorage), Zone - (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). - Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :param zone_redundant: Whether or not the multi-az is enabled. - :type zone_redundant: bool - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory administrator of the server. - :type administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :param service_principal: The managed instance's service principal. - :type service_principal: ~azure.mgmt.sql.models.ServicePrincipal - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'fully_qualified_domain_name': {'readonly': True}, - 'state': {'readonly': True}, - 'dns_zone': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'current_backup_storage_redundancy': {'readonly': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'managed_instance_create_mode': {'key': 'properties.managedInstanceCreateMode', 'type': 'str'}, - 'fully_qualified_domain_name': {'key': 'properties.fullyQualifiedDomainName', 'type': 'str'}, - 'administrator_login': {'key': 'properties.administratorLogin', 'type': 'str'}, - 'administrator_login_password': {'key': 'properties.administratorLoginPassword', 'type': 'str'}, - 'subnet_id': {'key': 'properties.subnetId', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'license_type': {'key': 'properties.licenseType', 'type': 'str'}, - 'v_cores': {'key': 'properties.vCores', 'type': 'int'}, - 'storage_size_in_gb': {'key': 'properties.storageSizeInGB', 'type': 'int'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'dns_zone': {'key': 'properties.dnsZone', 'type': 'str'}, - 'dns_zone_partner': {'key': 'properties.dnsZonePartner', 'type': 'str'}, - 'public_data_endpoint_enabled': {'key': 'properties.publicDataEndpointEnabled', 'type': 'bool'}, - 'source_managed_instance_id': {'key': 'properties.sourceManagedInstanceId', 'type': 'str'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'proxy_override': {'key': 'properties.proxyOverride', 'type': 'str'}, - 'timezone_id': {'key': 'properties.timezoneId', 'type': 'str'}, - 'instance_pool_id': {'key': 'properties.instancePoolId', 'type': 'str'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[ManagedInstancePecProperty]'}, - 'minimal_tls_version': {'key': 'properties.minimalTlsVersion', 'type': 'str'}, - 'current_backup_storage_redundancy': {'key': 'properties.currentBackupStorageRedundancy', 'type': 'str'}, - 'requested_backup_storage_redundancy': {'key': 'properties.requestedBackupStorageRedundancy', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'primary_user_assigned_identity_id': {'key': 'properties.primaryUserAssignedIdentityId', 'type': 'str'}, - 'key_id': {'key': 'properties.keyId', 'type': 'str'}, - 'administrators': {'key': 'properties.administrators', 'type': 'ManagedInstanceExternalAdministrator'}, - 'service_principal': {'key': 'properties.servicePrincipal', 'type': 'ServicePrincipal'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceUpdate, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.tags = kwargs.get('tags', None) - self.provisioning_state = None - self.managed_instance_create_mode = kwargs.get('managed_instance_create_mode', None) - self.fully_qualified_domain_name = None - self.administrator_login = kwargs.get('administrator_login', None) - self.administrator_login_password = kwargs.get('administrator_login_password', None) - self.subnet_id = kwargs.get('subnet_id', None) - self.state = None - self.license_type = kwargs.get('license_type', None) - self.v_cores = kwargs.get('v_cores', None) - self.storage_size_in_gb = kwargs.get('storage_size_in_gb', None) - self.collation = kwargs.get('collation', None) - self.dns_zone = None - self.dns_zone_partner = kwargs.get('dns_zone_partner', None) - self.public_data_endpoint_enabled = kwargs.get('public_data_endpoint_enabled', None) - self.source_managed_instance_id = kwargs.get('source_managed_instance_id', None) - self.restore_point_in_time = kwargs.get('restore_point_in_time', None) - self.proxy_override = kwargs.get('proxy_override', None) - self.timezone_id = kwargs.get('timezone_id', None) - self.instance_pool_id = kwargs.get('instance_pool_id', None) - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - self.private_endpoint_connections = None - self.minimal_tls_version = kwargs.get('minimal_tls_version', None) - self.current_backup_storage_redundancy = None - self.requested_backup_storage_redundancy = kwargs.get('requested_backup_storage_redundancy', None) - self.zone_redundant = kwargs.get('zone_redundant', None) - self.primary_user_assigned_identity_id = kwargs.get('primary_user_assigned_identity_id', None) - self.key_id = kwargs.get('key_id', None) - self.administrators = kwargs.get('administrators', None) - self.service_principal = kwargs.get('service_principal', None) - - -class ManagedInstanceVcoresCapability(msrest.serialization.Model): - """The managed instance virtual cores capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The virtual cores identifier. - :vartype name: str - :ivar value: The virtual cores value. - :vartype value: int - :ivar included_max_size: Included size. - :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar supported_storage_sizes: Storage size ranges. - :vartype supported_storage_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar instance_pool_supported: True if this service objective is supported for managed - instances in an instance pool. - :vartype instance_pool_supported: bool - :ivar standalone_supported: True if this service objective is supported for standalone managed - instances. - :vartype standalone_supported: bool - :ivar supported_maintenance_configurations: List of supported maintenance configurations. - :vartype supported_maintenance_configurations: - list[~azure.mgmt.sql.models.ManagedInstanceMaintenanceConfigurationCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, - 'included_max_size': {'readonly': True}, - 'supported_storage_sizes': {'readonly': True}, - 'instance_pool_supported': {'readonly': True}, - 'standalone_supported': {'readonly': True}, - 'supported_maintenance_configurations': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, - 'included_max_size': {'key': 'includedMaxSize', 'type': 'MaxSizeCapability'}, - 'supported_storage_sizes': {'key': 'supportedStorageSizes', 'type': '[MaxSizeRangeCapability]'}, - 'instance_pool_supported': {'key': 'instancePoolSupported', 'type': 'bool'}, - 'standalone_supported': {'key': 'standaloneSupported', 'type': 'bool'}, - 'supported_maintenance_configurations': {'key': 'supportedMaintenanceConfigurations', 'type': '[ManagedInstanceMaintenanceConfigurationCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceVcoresCapability, self).__init__(**kwargs) - self.name = None - self.value = None - self.included_max_size = None - self.supported_storage_sizes = None - self.instance_pool_supported = None - self.standalone_supported = None - self.supported_maintenance_configurations = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ManagedInstanceVersionCapability(msrest.serialization.Model): - """The managed instance capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The server version name. - :vartype name: str - :ivar supported_editions: The list of supported managed instance editions. - :vartype supported_editions: list[~azure.mgmt.sql.models.ManagedInstanceEditionCapability] - :ivar supported_instance_pool_editions: The list of supported instance pool editions. - :vartype supported_instance_pool_editions: - list[~azure.mgmt.sql.models.InstancePoolEditionCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_editions': {'readonly': True}, - 'supported_instance_pool_editions': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_editions': {'key': 'supportedEditions', 'type': '[ManagedInstanceEditionCapability]'}, - 'supported_instance_pool_editions': {'key': 'supportedInstancePoolEditions', 'type': '[InstancePoolEditionCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceVersionCapability, self).__init__(**kwargs) - self.name = None - self.supported_editions = None - self.supported_instance_pool_editions = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ManagedInstanceVulnerabilityAssessment(ProxyResource): - """A managed instance vulnerability assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). - :type storage_container_path: str - :param storage_container_sas_key: A shared access signature (SAS Key) that has write access to - the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' - isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not - behind a Vnet or a firewall. - :type storage_container_sas_key: str - :param storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet - or a firewall. - :type storage_account_access_key: str - :param recurring_scans: The recurring scans settings. - :type recurring_scans: ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_container_path': {'key': 'properties.storageContainerPath', 'type': 'str'}, - 'storage_container_sas_key': {'key': 'properties.storageContainerSasKey', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'recurring_scans': {'key': 'properties.recurringScans', 'type': 'VulnerabilityAssessmentRecurringScansProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceVulnerabilityAssessment, self).__init__(**kwargs) - self.storage_container_path = kwargs.get('storage_container_path', None) - self.storage_container_sas_key = kwargs.get('storage_container_sas_key', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.recurring_scans = kwargs.get('recurring_scans', None) - - -class ManagedInstanceVulnerabilityAssessmentListResult(msrest.serialization.Model): - """A list of the ManagedInstance's vulnerability assessments. - - 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.ManagedInstanceVulnerabilityAssessment] - :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': '[ManagedInstanceVulnerabilityAssessment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedInstanceVulnerabilityAssessmentListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedServerSecurityAlertPolicy(ProxyResource): - """A managed server security alert policy. - - 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 SecurityAlertPolicyResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Possible values include: "Enabled", - "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int - :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'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedServerSecurityAlertPolicy, self).__init__(**kwargs) - self.system_data = None - self.state = kwargs.get('state', None) - self.disabled_alerts = kwargs.get('disabled_alerts', None) - self.email_addresses = kwargs.get('email_addresses', None) - self.email_account_admins = kwargs.get('email_account_admins', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.retention_days = kwargs.get('retention_days', None) - self.creation_time = None - - -class ManagedServerSecurityAlertPolicyListResult(msrest.serialization.Model): - """A list of the managed Server's security alert policies. - - 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.ManagedServerSecurityAlertPolicy] - :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': '[ManagedServerSecurityAlertPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedServerSecurityAlertPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ManagedTransparentDataEncryption(ProxyResource): - """A managed database transparent data encryption state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param state: Specifies the state of the transparent data encryption. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedTransparentDataEncryption, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - - -class ManagedTransparentDataEncryptionListResult(msrest.serialization.Model): - """A list of managed transparent data encryptions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] - :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': '[ManagedTransparentDataEncryption]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedTransparentDataEncryptionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class MaxSizeCapability(msrest.serialization.Model): - """The maximum size capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The maximum size limit (see 'unit' for the units). - :vartype limit: int - :ivar unit: The units that the limit is expressed in. Possible values include: "Megabytes", - "Gigabytes", "Terabytes", "Petabytes". - :vartype unit: str or ~azure.mgmt.sql.models.MaxSizeUnit - """ - - _validation = { - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - } - - _attribute_map = { - 'limit': {'key': 'limit', 'type': 'int'}, - 'unit': {'key': 'unit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MaxSizeCapability, self).__init__(**kwargs) - self.limit = None - self.unit = None - - -class MaxSizeRangeCapability(msrest.serialization.Model): - """The maximum size range capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar min_value: Minimum value. - :vartype min_value: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar max_value: Maximum value. - :vartype max_value: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar scale_size: Scale/step size for discrete values between the minimum value and the maximum - value. - :vartype scale_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar log_size: Size of transaction log. - :vartype log_size: ~azure.mgmt.sql.models.LogSizeCapability - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'min_value': {'readonly': True}, - 'max_value': {'readonly': True}, - 'scale_size': {'readonly': True}, - 'log_size': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'min_value': {'key': 'minValue', 'type': 'MaxSizeCapability'}, - 'max_value': {'key': 'maxValue', 'type': 'MaxSizeCapability'}, - 'scale_size': {'key': 'scaleSize', 'type': 'MaxSizeCapability'}, - 'log_size': {'key': 'logSize', 'type': 'LogSizeCapability'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MaxSizeRangeCapability, self).__init__(**kwargs) - self.min_value = None - self.max_value = None - self.scale_size = None - self.log_size = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class Metric(msrest.serialization.Model): - """Database metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: ~datetime.datetime - :ivar time_grain: The time step to be used to summarize the metric values. - :vartype time_grain: str - :ivar unit: The unit of the metric. Possible values include: "count", "bytes", "seconds", - "percent", "countPerSecond", "bytesPerSecond". - :vartype unit: str or ~azure.mgmt.sql.models.UnitType - :ivar name: The name information for the metric. - :vartype name: ~azure.mgmt.sql.models.MetricName - :ivar metric_values: The metric values for the specified time window and timestep. - :vartype metric_values: list[~azure.mgmt.sql.models.MetricValue] - """ - - _validation = { - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'time_grain': {'readonly': True}, - 'unit': {'readonly': True}, - 'name': {'readonly': True}, - 'metric_values': {'readonly': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'time_grain': {'key': 'timeGrain', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, - 'metric_values': {'key': 'metricValues', 'type': '[MetricValue]'}, - } - - def __init__( - self, - **kwargs - ): - super(Metric, self).__init__(**kwargs) - self.start_time = None - self.end_time = None - self.time_grain = None - self.unit = None - self.name = None - self.metric_values = None - - -class MetricAvailability(msrest.serialization.Model): - """A metric availability value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar retention: The length of retention for the database metric. - :vartype retention: str - :ivar time_grain: The granularity of the database metric. - :vartype time_grain: str - """ - - _validation = { - 'retention': {'readonly': True}, - 'time_grain': {'readonly': True}, - } - - _attribute_map = { - 'retention': {'key': 'retention', 'type': 'str'}, - 'time_grain': {'key': 'timeGrain', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAvailability, self).__init__(**kwargs) - self.retention = None - self.time_grain = None - - -class MetricDefinition(msrest.serialization.Model): - """A database metric definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name information for the metric. - :vartype name: ~azure.mgmt.sql.models.MetricName - :ivar primary_aggregation_type: The primary aggregation type defining how metric values are - displayed. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :vartype primary_aggregation_type: str or ~azure.mgmt.sql.models.PrimaryAggregationType - :ivar resource_uri: The resource uri of the database. - :vartype resource_uri: str - :ivar unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", - "Percent", "CountPerSecond", "BytesPerSecond". - :vartype unit: str or ~azure.mgmt.sql.models.UnitDefinitionType - :ivar metric_availabilities: The list of database metric availabilities for the metric. - :vartype metric_availabilities: list[~azure.mgmt.sql.models.MetricAvailability] - """ - - _validation = { - 'name': {'readonly': True}, - 'primary_aggregation_type': {'readonly': True}, - 'resource_uri': {'readonly': True}, - 'unit': {'readonly': True}, - 'metric_availabilities': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'MetricName'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinition, self).__init__(**kwargs) - self.name = None - self.primary_aggregation_type = None - self.resource_uri = None - self.unit = None - self.metric_availabilities = None - - -class MetricDefinitionListResult(msrest.serialization.Model): - """The response to a list database metric definitions request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of metric definitions for the database. - :type value: list[~azure.mgmt.sql.models.MetricDefinition] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class MetricListResult(msrest.serialization.Model): - """The response to a list database metrics request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of metrics for the database. - :type value: list[~azure.mgmt.sql.models.Metric] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Metric]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class MetricName(msrest.serialization.Model): - """A database metric name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The name of the database metric. - :vartype value: str - :ivar localized_value: The friendly name of the database metric. - :vartype localized_value: str - """ - - _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricName, self).__init__(**kwargs) - self.value = None - self.localized_value = None - - -class MetricValue(msrest.serialization.Model): - """Represents database metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar count: The number of values for the metric. - :vartype count: int - :ivar average: The average value of the metric. - :vartype average: float - :ivar maximum: The max value of the metric. - :vartype maximum: float - :ivar minimum: The min value of the metric. - :vartype minimum: float - :ivar timestamp: The metric timestamp (ISO-8601 format). - :vartype timestamp: ~datetime.datetime - :ivar total: The total value of the metric. - :vartype total: float - """ - - _validation = { - 'count': {'readonly': True}, - 'average': {'readonly': True}, - 'maximum': {'readonly': True}, - 'minimum': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'total': {'readonly': True}, - } - - _attribute_map = { - 'count': {'key': 'count', 'type': 'int'}, - 'average': {'key': 'average', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'total': {'key': 'total', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricValue, self).__init__(**kwargs) - self.count = None - self.average = None - self.maximum = None - self.minimum = None - self.timestamp = None - self.total = None - - -class MinCapacityCapability(msrest.serialization.Model): - """The min capacity capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Min capacity value. - :vartype value: float - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'value': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'float'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MinCapacityCapability, self).__init__(**kwargs) - self.value = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class Name(msrest.serialization.Model): - """ARM Usage Name. - - :param value: Usage name value. - :type value: str - :param localized_value: Usage name localized value. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class NetworkIsolationSettings(msrest.serialization.Model): - """Contains the ARM resources for which to create private endpoint connection. - - :param storage_account_resource_id: The resource id for the storage account used to store - BACPAC file. If set, private endpoint connection will be created for the storage account. Must - match storage account used for StorageUri parameter. - :type storage_account_resource_id: str - :param sql_server_resource_id: The resource id for the SQL server which is the target of this - request. If set, private endpoint connection will be created for the SQL server. Must match - server which is target of the operation. - :type sql_server_resource_id: str - """ - - _attribute_map = { - 'storage_account_resource_id': {'key': 'storageAccountResourceId', 'type': 'str'}, - 'sql_server_resource_id': {'key': 'sqlServerResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkIsolationSettings, self).__init__(**kwargs) - self.storage_account_resource_id = kwargs.get('storage_account_resource_id', None) - self.sql_server_resource_id = kwargs.get('sql_server_resource_id', None) - - -class Operation(msrest.serialization.Model): - """SQL REST API operation definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation being performed on this particular object. - :vartype name: str - :ivar display: The localized display information for this particular operation / action. - :vartype display: ~azure.mgmt.sql.models.OperationDisplay - :ivar origin: The intended executor of the operation. Possible values include: "user", - "system". - :vartype origin: str or ~azure.mgmt.sql.models.OperationOrigin - :ivar properties: Additional descriptions for the operation. - :vartype properties: dict[str, any] - """ - - _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, - 'origin': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = None - self.origin = None - self.properties = None - - -class OperationDisplay(msrest.serialization.Model): - """Display metadata associated with the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name. - :vartype provider: str - :ivar resource: The localized friendly form of the resource type related to this - action/operation. - :vartype resource: str - :ivar operation: The localized friendly name for the operation. - :vartype operation: str - :ivar description: The localized friendly description for the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationImpact(msrest.serialization.Model): - """The impact of an operation, both in absolute and relative terms. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the impact dimension. - :vartype name: str - :ivar unit: The unit in which estimated impact to dimension is measured. - :vartype unit: str - :ivar change_value_absolute: The absolute impact to dimension. - :vartype change_value_absolute: float - :ivar change_value_relative: The relative impact to dimension (null if not applicable). - :vartype change_value_relative: float - """ - - _validation = { - 'name': {'readonly': True}, - 'unit': {'readonly': True}, - 'change_value_absolute': {'readonly': True}, - 'change_value_relative': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'change_value_absolute': {'key': 'changeValueAbsolute', 'type': 'float'}, - 'change_value_relative': {'key': 'changeValueRelative', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationImpact, self).__init__(**kwargs) - self.name = None - self.unit = None - self.change_value_absolute = None - self.change_value_relative = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list SQL operations. - - 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.Operation] - :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': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OperationsHealth(ProxyResource): - """Operations health status in a location. - - 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 name_properties_name: Operation name for the service. - :vartype name_properties_name: str - :ivar health: Operation health status of the service. - :vartype health: str - :ivar description: Health status description. - :vartype description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'name_properties_name': {'readonly': True}, - 'health': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'health': {'key': 'properties.health', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsHealth, self).__init__(**kwargs) - self.name_properties_name = None - self.health = None - self.description = None - - -class OperationsHealthListResult(msrest.serialization.Model): - """A list of service health statuses in a location. - - 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.OperationsHealth] - :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': '[OperationsHealth]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsHealthListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OutboundFirewallRule(ProxyResource): - """An Azure SQL DB Server Outbound Firewall Rule. - - 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 provisioning_state: The state of the outbound rule. - :vartype provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OutboundFirewallRule, self).__init__(**kwargs) - self.provisioning_state = None - - -class OutboundFirewallRuleListResult(msrest.serialization.Model): - """A list of outbound rules. - - 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.OutboundFirewallRule] - :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': '[OutboundFirewallRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OutboundFirewallRuleListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PartnerInfo(msrest.serialization.Model): - """Partner server information for the failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource identifier of the partner server. - :type id: str - :ivar location: Geo location of the partner server. - :vartype location: str - :ivar replication_role: Replication role of the partner server. Possible values include: - "Primary", "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.FailoverGroupReplicationRole - """ - - _validation = { - 'id': {'required': True}, - 'location': {'readonly': True}, - 'replication_role': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'replication_role': {'key': 'replicationRole', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PartnerInfo, self).__init__(**kwargs) - self.id = kwargs['id'] - self.location = None - self.replication_role = None - - -class PartnerRegionInfo(msrest.serialization.Model): - """Partner region information for the failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param location: Geo location of the partner managed instances. - :type location: str - :ivar replication_role: Replication role of the partner managed instances. Possible values - include: "Primary", "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole - """ - - _validation = { - 'replication_role': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'replication_role': {'key': 'replicationRole', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PartnerRegionInfo, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.replication_role = None - - -class PerformanceLevelCapability(msrest.serialization.Model): - """The performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Performance level value. - :vartype value: float - :ivar unit: Unit type used to measure performance level. Possible values include: "DTU", - "VCores". - :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit - """ - - _validation = { - 'value': {'readonly': True}, - 'unit': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PerformanceLevelCapability, self).__init__(**kwargs) - self.value = None - self.unit = None - - -class PrivateEndpointConnection(ProxyResource): - """A private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty - :param private_link_service_connection_state: Connection state of the private endpoint - connection. - :type private_link_service_connection_state: - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the private endpoint connection. Possible values include: - "Approving", "Ready", "Dropping", "Failed", "Rejecting". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.PrivateEndpointProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = None - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """A list of private endpoint connections. - - 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.PrivateEndpointConnection] - :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': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpointConnectionProperties(msrest.serialization.Model): - """Properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty - :param private_link_service_connection_state: Connection state of the private endpoint - connection. - :type private_link_service_connection_state: - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the private endpoint connection. Possible values include: - "Approving", "Ready", "Dropping", "Failed", "Rejecting". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.PrivateEndpointProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = None - - -class PrivateEndpointConnectionRequestStatus(msrest.serialization.Model): - """Contains the private endpoint connection requests status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar private_link_service_id: Resource id for which the private endpoint is created. - :vartype private_link_service_id: str - :ivar private_endpoint_connection_name: The connection name for the private endpoint. - :vartype private_endpoint_connection_name: str - :ivar status: Status of this private endpoint connection. - :vartype status: str - """ - - _validation = { - 'private_link_service_id': {'readonly': True}, - 'private_endpoint_connection_name': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'private_link_service_id': {'key': 'privateLinkServiceId', 'type': 'str'}, - 'private_endpoint_connection_name': {'key': 'privateEndpointConnectionName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionRequestStatus, self).__init__(**kwargs) - self.private_link_service_id = None - self.private_endpoint_connection_name = None - self.status = None - - -class PrivateEndpointProperty(msrest.serialization.Model): - """PrivateEndpointProperty. - - :param id: Resource id of the private endpoint. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointProperty, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class PrivateLinkResource(ProxyResource): - """A private link resource. - - 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 properties: The private link resource group id. - :vartype properties: ~azure.mgmt.sql.models.PrivateLinkResourceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.properties = None - - -class PrivateLinkResourceListResult(msrest.serialization.Model): - """A list of private link resources. - - 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.PrivateLinkResource] - :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': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateLinkResourceProperties(msrest.serialization.Model): - """Properties of a private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource required zone names. - :vartype required_zone_names: list[str] - """ - - _validation = { - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - 'required_zone_names': {'readonly': True}, - } - - _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceProperties, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = None - - -class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): - """PrivateLinkServiceConnectionStateProperty. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus - :param description: Required. The private link service connection description. - :type description: str - :ivar actions_required: The actions required for private link service connection. Possible - values include: "None". - :vartype actions_required: str or - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateActionsRequire - """ - - _validation = { - 'status': {'required': True}, - 'description': {'required': True}, - 'actions_required': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs['description'] - self.actions_required = None - - -class QueryMetricInterval(msrest.serialization.Model): - """Properties of a query metrics interval. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar interval_start_time: The start time for the metric interval (ISO-8601 format). - :vartype interval_start_time: str - :ivar interval_type: Interval type (length). Possible values include: "PT1H", "P1D". - :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :ivar execution_count: Execution count of a query in this interval. - :vartype execution_count: long - :param metrics: List of metric objects for this interval. - :type metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] - """ - - _validation = { - 'interval_start_time': {'readonly': True}, - 'interval_type': {'readonly': True}, - 'execution_count': {'readonly': True}, - } - - _attribute_map = { - 'interval_start_time': {'key': 'intervalStartTime', 'type': 'str'}, - 'interval_type': {'key': 'intervalType', 'type': 'str'}, - 'execution_count': {'key': 'executionCount', 'type': 'long'}, - 'metrics': {'key': 'metrics', 'type': '[QueryMetricProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryMetricInterval, self).__init__(**kwargs) - self.interval_start_time = None - self.interval_type = None - self.execution_count = None - self.metrics = kwargs.get('metrics', None) - - -class QueryMetricProperties(msrest.serialization.Model): - """Properties of a topquery metric in one interval. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name information for the metric. - :vartype name: str - :ivar display_name: The UI appropriate name for the metric. - :vartype display_name: str - :ivar unit: The unit of the metric. Possible values include: "percentage", "KB", - "microseconds", "count". - :vartype unit: str or ~azure.mgmt.sql.models.QueryMetricUnitType - :ivar value: The value of the metric. - :vartype value: float - :ivar min: Metric value when min() aggregate function is used over the interval. - :vartype min: float - :ivar max: Metric value when max() aggregate function is used over the interval. - :vartype max: float - :ivar avg: Metric value when avg() aggregate function is used over the interval. - :vartype avg: float - :ivar sum: Metric value when sum() aggregate function is used over the interval. - :vartype sum: float - :ivar stdev: Metric value when stdev aggregate function is used over the interval. - :vartype stdev: float - """ - - _validation = { - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'unit': {'readonly': True}, - 'value': {'readonly': True}, - 'min': {'readonly': True}, - 'max': {'readonly': True}, - 'avg': {'readonly': True}, - 'sum': {'readonly': True}, - 'stdev': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, - 'min': {'key': 'min', 'type': 'float'}, - 'max': {'key': 'max', 'type': 'float'}, - 'avg': {'key': 'avg', 'type': 'float'}, - 'sum': {'key': 'sum', 'type': 'float'}, - 'stdev': {'key': 'stdev', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryMetricProperties, self).__init__(**kwargs) - self.name = None - self.display_name = None - self.unit = None - self.value = None - self.min = None - self.max = None - self.avg = None - self.sum = None - self.stdev = None - - -class QueryStatistics(ProxyResource): - """QueryStatistics. - - 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 database_name: Database name of the database in which this query was executed. - :vartype database_name: str - :ivar query_id: Unique query id (unique within one database). - :vartype query_id: str - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: str - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: str - :param intervals: List of intervals with appropriate metric data. - :type intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'database_name': {'readonly': True}, - 'query_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'query_id': {'key': 'properties.queryId', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'str'}, - 'end_time': {'key': 'properties.endTime', 'type': 'str'}, - 'intervals': {'key': 'properties.intervals', 'type': '[QueryMetricInterval]'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryStatistics, self).__init__(**kwargs) - self.database_name = None - self.query_id = None - self.start_time = None - self.end_time = None - self.intervals = kwargs.get('intervals', None) - - -class QueryStatisticsProperties(msrest.serialization.Model): - """Properties of a query execution statistics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar database_name: Database name of the database in which this query was executed. - :vartype database_name: str - :ivar query_id: Unique query id (unique within one database). - :vartype query_id: str - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: str - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: str - :param intervals: List of intervals with appropriate metric data. - :type intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] - """ - - _validation = { - 'database_name': {'readonly': True}, - 'query_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'query_id': {'key': 'queryId', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - 'intervals': {'key': 'intervals', 'type': '[QueryMetricInterval]'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryStatisticsProperties, self).__init__(**kwargs) - self.database_name = None - self.query_id = None - self.start_time = None - self.end_time = None - self.intervals = kwargs.get('intervals', None) - - -class ReadScaleCapability(msrest.serialization.Model): - """The read scale capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar max_number_of_replicas: The maximum number of read scale replicas. - :vartype max_number_of_replicas: int - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'max_number_of_replicas': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'max_number_of_replicas': {'key': 'maxNumberOfReplicas', 'type': 'int'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReadScaleCapability, self).__init__(**kwargs) - self.max_number_of_replicas = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class RecommendedAction(ProxyResource): - """Database, Server or Elastic Pool Recommended Action. - - 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 kind: Resource kind. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar recommendation_reason: Gets the reason for recommending this action. e.g., - DuplicateIndex. - :vartype recommendation_reason: str - :ivar valid_since: Gets the time since when this recommended action is valid. - :vartype valid_since: ~datetime.datetime - :ivar last_refresh: Gets time when this recommended action was last refreshed. - :vartype last_refresh: ~datetime.datetime - :param state: Gets the info of the current state the recommended action is in. - :type state: ~azure.mgmt.sql.models.RecommendedActionStateInfo - :ivar is_executable_action: Gets if this recommended action is actionable by user. - :vartype is_executable_action: bool - :ivar is_revertable_action: Gets if changes applied by this recommended action can be reverted - by user. - :vartype is_revertable_action: bool - :ivar is_archived_action: Gets if this recommended action was suggested some time ago but user - chose to ignore this and system added a new recommended action again. - :vartype is_archived_action: bool - :ivar execute_action_start_time: Gets the time when system started applying this recommended - action on the user resource. e.g., index creation start time. - :vartype execute_action_start_time: ~datetime.datetime - :ivar execute_action_duration: Gets the time taken for applying this recommended action on user - resource. e.g., time taken for index creation. - :vartype execute_action_duration: str - :ivar revert_action_start_time: Gets the time when system started reverting changes of this - recommended action on user resource. e.g., time when index drop is executed. - :vartype revert_action_start_time: ~datetime.datetime - :ivar revert_action_duration: Gets the time taken for reverting changes of this recommended - action on user resource. e.g., time taken for dropping the created index. - :vartype revert_action_duration: str - :ivar execute_action_initiated_by: Gets if approval for applying this recommended action was - given by user/system. Possible values include: "User", "System". - :vartype execute_action_initiated_by: str or - ~azure.mgmt.sql.models.RecommendedActionInitiatedBy - :ivar execute_action_initiated_time: Gets the time when this recommended action was approved - for execution. - :vartype execute_action_initiated_time: ~datetime.datetime - :ivar revert_action_initiated_by: Gets if approval for reverting this recommended action was - given by user/system. Possible values include: "User", "System". - :vartype revert_action_initiated_by: str or ~azure.mgmt.sql.models.RecommendedActionInitiatedBy - :ivar revert_action_initiated_time: Gets the time when this recommended action was approved for - revert. - :vartype revert_action_initiated_time: ~datetime.datetime - :ivar score: Gets the impact of this recommended action. Possible values are 1 - Low impact, 2 - - Medium Impact and 3 - High Impact. - :vartype score: int - :ivar implementation_details: Gets the implementation details of this recommended action for - user to apply it manually. - :vartype implementation_details: ~azure.mgmt.sql.models.RecommendedActionImplementationInfo - :ivar error_details: Gets the error details if and why this recommended action is put to error - state. - :vartype error_details: ~azure.mgmt.sql.models.RecommendedActionErrorInfo - :ivar estimated_impact: Gets the estimated impact info for this recommended action e.g., - Estimated CPU gain, Estimated Disk Space change. - :vartype estimated_impact: list[~azure.mgmt.sql.models.RecommendedActionImpactRecord] - :ivar observed_impact: Gets the observed/actual impact info for this recommended action e.g., - Actual CPU gain, Actual Disk Space change. - :vartype observed_impact: list[~azure.mgmt.sql.models.RecommendedActionImpactRecord] - :ivar time_series: Gets the time series info of metrics for this recommended action e.g., CPU - consumption time series. - :vartype time_series: list[~azure.mgmt.sql.models.RecommendedActionMetricInfo] - :ivar linked_objects: Gets the linked objects, if any. - :vartype linked_objects: list[str] - :ivar details: Gets additional details specific to this recommended action. - :vartype details: dict[str, any] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, - 'recommendation_reason': {'readonly': True}, - 'valid_since': {'readonly': True}, - 'last_refresh': {'readonly': True}, - 'is_executable_action': {'readonly': True}, - 'is_revertable_action': {'readonly': True}, - 'is_archived_action': {'readonly': True}, - 'execute_action_start_time': {'readonly': True}, - 'execute_action_duration': {'readonly': True}, - 'revert_action_start_time': {'readonly': True}, - 'revert_action_duration': {'readonly': True}, - 'execute_action_initiated_by': {'readonly': True}, - 'execute_action_initiated_time': {'readonly': True}, - 'revert_action_initiated_by': {'readonly': True}, - 'revert_action_initiated_time': {'readonly': True}, - 'score': {'readonly': True}, - 'implementation_details': {'readonly': True}, - 'error_details': {'readonly': True}, - 'estimated_impact': {'readonly': True}, - 'observed_impact': {'readonly': True}, - 'time_series': {'readonly': True}, - 'linked_objects': {'readonly': True}, - 'details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'recommendation_reason': {'key': 'properties.recommendationReason', 'type': 'str'}, - 'valid_since': {'key': 'properties.validSince', 'type': 'iso-8601'}, - 'last_refresh': {'key': 'properties.lastRefresh', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'RecommendedActionStateInfo'}, - 'is_executable_action': {'key': 'properties.isExecutableAction', 'type': 'bool'}, - 'is_revertable_action': {'key': 'properties.isRevertableAction', 'type': 'bool'}, - 'is_archived_action': {'key': 'properties.isArchivedAction', 'type': 'bool'}, - 'execute_action_start_time': {'key': 'properties.executeActionStartTime', 'type': 'iso-8601'}, - 'execute_action_duration': {'key': 'properties.executeActionDuration', 'type': 'str'}, - 'revert_action_start_time': {'key': 'properties.revertActionStartTime', 'type': 'iso-8601'}, - 'revert_action_duration': {'key': 'properties.revertActionDuration', 'type': 'str'}, - 'execute_action_initiated_by': {'key': 'properties.executeActionInitiatedBy', 'type': 'str'}, - 'execute_action_initiated_time': {'key': 'properties.executeActionInitiatedTime', 'type': 'iso-8601'}, - 'revert_action_initiated_by': {'key': 'properties.revertActionInitiatedBy', 'type': 'str'}, - 'revert_action_initiated_time': {'key': 'properties.revertActionInitiatedTime', 'type': 'iso-8601'}, - 'score': {'key': 'properties.score', 'type': 'int'}, - 'implementation_details': {'key': 'properties.implementationDetails', 'type': 'RecommendedActionImplementationInfo'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'RecommendedActionErrorInfo'}, - 'estimated_impact': {'key': 'properties.estimatedImpact', 'type': '[RecommendedActionImpactRecord]'}, - 'observed_impact': {'key': 'properties.observedImpact', 'type': '[RecommendedActionImpactRecord]'}, - 'time_series': {'key': 'properties.timeSeries', 'type': '[RecommendedActionMetricInfo]'}, - 'linked_objects': {'key': 'properties.linkedObjects', 'type': '[str]'}, - 'details': {'key': 'properties.details', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedAction, self).__init__(**kwargs) - self.kind = None - self.location = None - self.recommendation_reason = None - self.valid_since = None - self.last_refresh = None - self.state = kwargs.get('state', None) - self.is_executable_action = None - self.is_revertable_action = None - self.is_archived_action = None - self.execute_action_start_time = None - self.execute_action_duration = None - self.revert_action_start_time = None - self.revert_action_duration = None - self.execute_action_initiated_by = None - self.execute_action_initiated_time = None - self.revert_action_initiated_by = None - self.revert_action_initiated_time = None - self.score = None - self.implementation_details = None - self.error_details = None - self.estimated_impact = None - self.observed_impact = None - self.time_series = None - self.linked_objects = None - self.details = None - - -class RecommendedActionErrorInfo(msrest.serialization.Model): - """Contains error information for an Azure SQL Database, Server or Elastic Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Gets the reason why the recommended action was put to error state. e.g., - DatabaseHasQdsOff, IndexAlreadyExists. - :vartype error_code: str - :ivar is_retryable: Gets whether the error could be ignored and recommended action could be - retried. Possible values are: Yes/No. Possible values include: "Yes", "No". - :vartype is_retryable: str or ~azure.mgmt.sql.models.IsRetryable - """ - - _validation = { - 'error_code': {'readonly': True}, - 'is_retryable': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'is_retryable': {'key': 'isRetryable', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedActionErrorInfo, self).__init__(**kwargs) - self.error_code = None - self.is_retryable = None - - -class RecommendedActionImpactRecord(msrest.serialization.Model): - """Contains information of estimated or observed impact on various metrics for an Azure SQL Database, Server or Elastic Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar dimension_name: Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, - NumberOfQueriesAffected. - :vartype dimension_name: str - :ivar unit: Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, - NumberOfQueriesAffected. - :vartype unit: str - :ivar absolute_value: Gets the absolute value of this dimension if applicable. e.g., Number of - Queries affected. - :vartype absolute_value: float - :ivar change_value_absolute: Gets the absolute change in the value of this dimension. e.g., - Absolute Disk space change in Megabytes. - :vartype change_value_absolute: float - :ivar change_value_relative: Gets the relative change in the value of this dimension. e.g., - Relative Disk space change in Percentage. - :vartype change_value_relative: float - """ - - _validation = { - 'dimension_name': {'readonly': True}, - 'unit': {'readonly': True}, - 'absolute_value': {'readonly': True}, - 'change_value_absolute': {'readonly': True}, - 'change_value_relative': {'readonly': True}, - } - - _attribute_map = { - 'dimension_name': {'key': 'dimensionName', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'absolute_value': {'key': 'absoluteValue', 'type': 'float'}, - 'change_value_absolute': {'key': 'changeValueAbsolute', 'type': 'float'}, - 'change_value_relative': {'key': 'changeValueRelative', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedActionImpactRecord, self).__init__(**kwargs) - self.dimension_name = None - self.unit = None - self.absolute_value = None - self.change_value_absolute = None - self.change_value_relative = None - - -class RecommendedActionImplementationInfo(msrest.serialization.Model): - """Contains information for manual implementation for an Azure SQL Database, Server or Elastic Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar method: Gets the method in which this recommended action can be manually implemented. - e.g., TSql, AzurePowerShell. Possible values include: "TSql", "AzurePowerShell". - :vartype method: str or ~azure.mgmt.sql.models.ImplementationMethod - :ivar script: Gets the manual implementation script. e.g., T-SQL script that could be executed - on the database. - :vartype script: str - """ - - _validation = { - 'method': {'readonly': True}, - 'script': {'readonly': True}, - } - - _attribute_map = { - 'method': {'key': 'method', 'type': 'str'}, - 'script': {'key': 'script', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedActionImplementationInfo, self).__init__(**kwargs) - self.method = None - self.script = None - - -class RecommendedActionMetricInfo(msrest.serialization.Model): - """Contains time series of various impacted metrics for an Azure SQL Database, Server or Elastic Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar metric_name: Gets the name of the metric. e.g., CPU, Number of Queries. - :vartype metric_name: str - :ivar unit: Gets the unit in which metric is measured. e.g., DTU, Frequency. - :vartype unit: str - :ivar time_grain: Gets the duration of time interval for the value given by this MetricInfo. - e.g., PT1H (1 hour). - :vartype time_grain: str - :ivar start_time: Gets the start time of time interval given by this MetricInfo. - :vartype start_time: ~datetime.datetime - :ivar value: Gets the value of the metric in the time interval given by this MetricInfo. - :vartype value: float - """ - - _validation = { - 'metric_name': {'readonly': True}, - 'unit': {'readonly': True}, - 'time_grain': {'readonly': True}, - 'start_time': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'time_grain': {'key': 'timeGrain', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'value': {'key': 'value', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedActionMetricInfo, self).__init__(**kwargs) - self.metric_name = None - self.unit = None - self.time_grain = None - self.start_time = None - self.value = None - - -class RecommendedActionStateInfo(msrest.serialization.Model): - """Contains information of current state for an Azure SQL Database, Server or Elastic Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param current_value: Required. Current state the recommended action is in. Some commonly used - states are: Active -> recommended action is active and no action has been taken yet. - Pending -> recommended action is approved for and is awaiting execution. Executing -> - recommended action is being applied on the user database. Verifying -> recommended action was - applied and is being verified of its usefulness by the system. Success -> recommended - action was applied and improvement found during verification. Pending Revert -> verification - found little or no improvement so recommended action is queued for revert or user has manually - reverted. Reverting -> changes made while applying recommended action are being reverted on - the user database. Reverted -> successfully reverted the changes made by recommended action - on user database. Ignored -> user explicitly ignored/discarded the recommended action. - Possible values include: "Active", "Pending", "Executing", "Verifying", "PendingRevert", - "RevertCancelled", "Reverting", "Reverted", "Ignored", "Expired", "Monitoring", "Resolved", - "Success", "Error". - :type current_value: str or ~azure.mgmt.sql.models.RecommendedActionCurrentState - :ivar action_initiated_by: Gets who initiated the execution of this recommended action. - Possible Value are: User -> When user explicity notified system to apply the recommended - action. System -> When auto-execute status of this advisor was set to 'Enabled', in which case - the system applied it. Possible values include: "User", "System". - :vartype action_initiated_by: str or ~azure.mgmt.sql.models.RecommendedActionInitiatedBy - :ivar last_modified: Gets the time when the state was last modified. - :vartype last_modified: ~datetime.datetime - """ - - _validation = { - 'current_value': {'required': True}, - 'action_initiated_by': {'readonly': True}, - 'last_modified': {'readonly': True}, - } - - _attribute_map = { - 'current_value': {'key': 'currentValue', 'type': 'str'}, - 'action_initiated_by': {'key': 'actionInitiatedBy', 'type': 'str'}, - 'last_modified': {'key': 'lastModified', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedActionStateInfo, self).__init__(**kwargs) - self.current_value = kwargs['current_value'] - self.action_initiated_by = None - self.last_modified = None - - -class RecommendedSensitivityLabelUpdate(ProxyResource): - """A recommended sensitivity label update operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param op: Possible values include: "enable", "disable". - :type op: str or ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind - :param schema: Schema name of the column to update. - :type schema: str - :param table: Table name of the column to update. - :type table: str - :param column: Column name to update. - :type column: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'op': {'key': 'properties.op', 'type': 'str'}, - 'schema': {'key': 'properties.schema', 'type': 'str'}, - 'table': {'key': 'properties.table', 'type': 'str'}, - 'column': {'key': 'properties.column', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedSensitivityLabelUpdate, self).__init__(**kwargs) - self.op = kwargs.get('op', None) - self.schema = kwargs.get('schema', None) - self.table = kwargs.get('table', None) - self.column = kwargs.get('column', None) - - -class RecommendedSensitivityLabelUpdateList(msrest.serialization.Model): - """A list of recommended sensitivity label update operations. - - :param operations: - :type operations: list[~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate] - """ - - _attribute_map = { - 'operations': {'key': 'operations', 'type': '[RecommendedSensitivityLabelUpdate]'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedSensitivityLabelUpdateList, self).__init__(**kwargs) - self.operations = kwargs.get('operations', None) - - -class RecoverableDatabase(ProxyResource): - """A recoverable database. - - 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 edition: The edition of the database. - :vartype edition: str - :ivar service_level_objective: The service level objective name of the database. - :vartype service_level_objective: str - :ivar elastic_pool_name: The elastic pool name of the database. - :vartype elastic_pool_name: str - :ivar last_available_backup_date: The last available backup date of the database (ISO8601 - format). - :vartype last_available_backup_date: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'edition': {'readonly': True}, - 'service_level_objective': {'readonly': True}, - 'elastic_pool_name': {'readonly': True}, - 'last_available_backup_date': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'edition': {'key': 'properties.edition', 'type': 'str'}, - 'service_level_objective': {'key': 'properties.serviceLevelObjective', 'type': 'str'}, - 'elastic_pool_name': {'key': 'properties.elasticPoolName', 'type': 'str'}, - 'last_available_backup_date': {'key': 'properties.lastAvailableBackupDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(RecoverableDatabase, self).__init__(**kwargs) - self.edition = None - self.service_level_objective = None - self.elastic_pool_name = None - self.last_available_backup_date = None - - -class RecoverableDatabaseListResult(msrest.serialization.Model): - """The response to a list recoverable databases request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. A list of recoverable databases. - :type value: list[~azure.mgmt.sql.models.RecoverableDatabase] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RecoverableDatabase]'}, - } - - def __init__( - self, - **kwargs - ): - super(RecoverableDatabaseListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class RecoverableManagedDatabase(ProxyResource): - """A recoverable managed database resource. - - 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 last_available_backup_date: The last available backup date. - :vartype last_available_backup_date: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_available_backup_date': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_available_backup_date': {'key': 'properties.lastAvailableBackupDate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecoverableManagedDatabase, self).__init__(**kwargs) - self.last_available_backup_date = None - - -class RecoverableManagedDatabaseListResult(msrest.serialization.Model): - """A list of recoverable managed databases. - - 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.RecoverableManagedDatabase] - :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': '[RecoverableManagedDatabase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecoverableManagedDatabaseListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ReplicationLink(ProxyResource): - """A replication link. - - 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 partner_server: Resource partner server. - :vartype partner_server: str - :ivar partner_database: Resource partner database. - :vartype partner_database: str - :ivar partner_location: Resource partner location. - :vartype partner_location: str - :ivar role: Local replication role. Possible values include: "Primary", "Secondary", - "NonReadableSecondary", "Source", "Copy". - :vartype role: str or ~azure.mgmt.sql.models.ReplicationRole - :ivar partner_role: Partner replication role. Possible values include: "Primary", "Secondary", - "NonReadableSecondary", "Source", "Copy". - :vartype partner_role: str or ~azure.mgmt.sql.models.ReplicationRole - :ivar replication_mode: Replication mode. - :vartype replication_mode: str - :ivar start_time: Time at which the link was created. - :vartype start_time: ~datetime.datetime - :ivar percent_complete: Seeding completion percentage for the link. - :vartype percent_complete: int - :ivar replication_state: Replication state (PENDING, SEEDING, CATCHUP, SUSPENDED). Possible - values include: "PENDING", "SEEDING", "CATCH_UP", "SUSPENDED". - :vartype replication_state: str or ~azure.mgmt.sql.models.ReplicationState - :ivar is_termination_allowed: Whether the user is currently allowed to terminate the link. - :vartype is_termination_allowed: bool - :ivar link_type: Link type (GEO, NAMED). Possible values include: "GEO", "NAMED". - :vartype link_type: str or ~azure.mgmt.sql.models.ReplicationLinkType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'partner_server': {'readonly': True}, - 'partner_database': {'readonly': True}, - 'partner_location': {'readonly': True}, - 'role': {'readonly': True}, - 'partner_role': {'readonly': True}, - 'replication_mode': {'readonly': True}, - 'start_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'replication_state': {'readonly': True}, - 'is_termination_allowed': {'readonly': True}, - 'link_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'partner_server': {'key': 'properties.partnerServer', 'type': 'str'}, - 'partner_database': {'key': 'properties.partnerDatabase', 'type': 'str'}, - 'partner_location': {'key': 'properties.partnerLocation', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - 'partner_role': {'key': 'properties.partnerRole', 'type': 'str'}, - 'replication_mode': {'key': 'properties.replicationMode', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'replication_state': {'key': 'properties.replicationState', 'type': 'str'}, - 'is_termination_allowed': {'key': 'properties.isTerminationAllowed', 'type': 'bool'}, - 'link_type': {'key': 'properties.linkType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReplicationLink, self).__init__(**kwargs) - self.partner_server = None - self.partner_database = None - self.partner_location = None - self.role = None - self.partner_role = None - self.replication_mode = None - self.start_time = None - self.percent_complete = None - self.replication_state = None - self.is_termination_allowed = None - self.link_type = None - - -class ReplicationLinkListResult(msrest.serialization.Model): - """A list of replication links. - - 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.ReplicationLink] - :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': '[ReplicationLink]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReplicationLinkListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ResourceIdentity(msrest.serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param user_assigned_identities: The resource ids of the user assigned identities to use. - :type user_assigned_identities: dict[str, ~azure.mgmt.sql.models.UserIdentity] - :ivar principal_id: The Azure Active Directory principal id. - :vartype principal_id: str - :param type: The identity type. Set this to 'SystemAssigned' in order to automatically create - and assign an Azure Active Directory principal for the resource. Possible values include: - "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". - :type type: str or ~azure.mgmt.sql.models.IdentityType - :ivar tenant_id: The Azure Active Directory tenant id. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentity}'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - self.principal_id = None - self.type = kwargs.get('type', None) - self.tenant_id = None - - -class ResourceMoveDefinition(msrest.serialization.Model): - """Contains the information necessary to perform a resource move (rename). - - All required parameters must be populated in order to send to Azure. - - :param id: Required. The target ID for the resource. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceMoveDefinition, self).__init__(**kwargs) - self.id = kwargs['id'] - - -class RestorableDroppedDatabase(ProxyResource): - """A restorable dropped database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar database_name: The name of the database. - :vartype database_name: str - :ivar max_size_bytes: The max size of the database expressed in bytes. - :vartype max_size_bytes: long - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar deletion_date: The deletion date of the database (ISO8601 format). - :vartype deletion_date: ~datetime.datetime - :ivar earliest_restore_date: The earliest restore date of the database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - :ivar backup_storage_redundancy: The storage account type used to store backups for this - database. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'database_name': {'readonly': True}, - 'max_size_bytes': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'deletion_date': {'readonly': True}, - 'earliest_restore_date': {'readonly': True}, - 'backup_storage_redundancy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'long'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'deletion_date': {'key': 'properties.deletionDate', 'type': 'iso-8601'}, - 'earliest_restore_date': {'key': 'properties.earliestRestoreDate', 'type': 'iso-8601'}, - 'backup_storage_redundancy': {'key': 'properties.backupStorageRedundancy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RestorableDroppedDatabase, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.database_name = None - self.max_size_bytes = None - self.creation_date = None - self.deletion_date = None - self.earliest_restore_date = None - self.backup_storage_redundancy = None - - -class RestorableDroppedDatabaseListResult(msrest.serialization.Model): - """A list of restorable dropped databases. - - 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.RestorableDroppedDatabase] - :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': '[RestorableDroppedDatabase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RestorableDroppedDatabaseListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RestorableDroppedManagedDatabase(TrackedResource): - """A restorable dropped managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar database_name: The name of the database. - :vartype database_name: str - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar deletion_date: The deletion date of the database (ISO8601 format). - :vartype deletion_date: ~datetime.datetime - :ivar earliest_restore_date: The earliest restore date of the database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'database_name': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'deletion_date': {'readonly': True}, - 'earliest_restore_date': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'deletion_date': {'key': 'properties.deletionDate', 'type': 'iso-8601'}, - 'earliest_restore_date': {'key': 'properties.earliestRestoreDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(RestorableDroppedManagedDatabase, self).__init__(**kwargs) - self.database_name = None - self.creation_date = None - self.deletion_date = None - self.earliest_restore_date = None - - -class RestorableDroppedManagedDatabaseListResult(msrest.serialization.Model): - """A list of restorable dropped managed databases. - - 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.RestorableDroppedManagedDatabase] - :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': '[RestorableDroppedManagedDatabase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RestorableDroppedManagedDatabaseListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RestorePoint(ProxyResource): - """Database restore points. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar restore_point_type: The type of restore point. Possible values include: "CONTINUOUS", - "DISCRETE". - :vartype restore_point_type: str or ~azure.mgmt.sql.models.RestorePointType - :ivar earliest_restore_date: The earliest time to which this database can be restored. - :vartype earliest_restore_date: ~datetime.datetime - :ivar restore_point_creation_date: The time the backup was taken. - :vartype restore_point_creation_date: ~datetime.datetime - :ivar restore_point_label: The label of restore point for backup request by user. - :vartype restore_point_label: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_point_type': {'readonly': True}, - 'earliest_restore_date': {'readonly': True}, - 'restore_point_creation_date': {'readonly': True}, - 'restore_point_label': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'restore_point_type': {'key': 'properties.restorePointType', 'type': 'str'}, - 'earliest_restore_date': {'key': 'properties.earliestRestoreDate', 'type': 'iso-8601'}, - 'restore_point_creation_date': {'key': 'properties.restorePointCreationDate', 'type': 'iso-8601'}, - 'restore_point_label': {'key': 'properties.restorePointLabel', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RestorePoint, self).__init__(**kwargs) - self.location = None - self.restore_point_type = None - self.earliest_restore_date = None - self.restore_point_creation_date = None - self.restore_point_label = None - - -class RestorePointListResult(msrest.serialization.Model): - """A list of long term retention backups. - - 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.RestorePoint] - :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': '[RestorePoint]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RestorePointListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityEvent(ProxyResource): - """A security event. - - 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 event_time: The time when the security event occurred. - :vartype event_time: ~datetime.datetime - :ivar security_event_type: The type of the security event. Possible values include: - "Undefined", "SqlInjectionVulnerability", "SqlInjectionExploit". - :vartype security_event_type: str or ~azure.mgmt.sql.models.SecurityEventType - :ivar subscription: The subscription name. - :vartype subscription: str - :ivar server: The server name. - :vartype server: str - :ivar database: The database name. - :vartype database: str - :ivar client_ip: The IP address of the client who executed the statement. - :vartype client_ip: str - :ivar application_name: The application used to execute the statement. - :vartype application_name: str - :ivar principal_name: The principal user who executed the statement. - :vartype principal_name: str - :ivar security_event_sql_injection_additional_properties: The sql injection additional - properties, populated only if the type of the security event is sql injection. - :vartype security_event_sql_injection_additional_properties: - ~azure.mgmt.sql.models.SecurityEventSqlInjectionAdditionalProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'event_time': {'readonly': True}, - 'security_event_type': {'readonly': True}, - 'subscription': {'readonly': True}, - 'server': {'readonly': True}, - 'database': {'readonly': True}, - 'client_ip': {'readonly': True}, - 'application_name': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'security_event_sql_injection_additional_properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'event_time': {'key': 'properties.eventTime', 'type': 'iso-8601'}, - 'security_event_type': {'key': 'properties.securityEventType', 'type': 'str'}, - 'subscription': {'key': 'properties.subscription', 'type': 'str'}, - 'server': {'key': 'properties.server', 'type': 'str'}, - 'database': {'key': 'properties.database', 'type': 'str'}, - 'client_ip': {'key': 'properties.clientIp', 'type': 'str'}, - 'application_name': {'key': 'properties.applicationName', 'type': 'str'}, - 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, - 'security_event_sql_injection_additional_properties': {'key': 'properties.securityEventSqlInjectionAdditionalProperties', 'type': 'SecurityEventSqlInjectionAdditionalProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SecurityEvent, self).__init__(**kwargs) - self.event_time = None - self.security_event_type = None - self.subscription = None - self.server = None - self.database = None - self.client_ip = None - self.application_name = None - self.principal_name = None - self.security_event_sql_injection_additional_properties = None - - -class SecurityEventCollection(msrest.serialization.Model): - """A list of security events. - - 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.SecurityEvent] - :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': '[SecurityEvent]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SecurityEventCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityEventsFilterParameters(msrest.serialization.Model): - """The properties that are supported in the $filter operation. - - :param event_time: Filter on the event time. - :type event_time: ~datetime.datetime - :param show_server_records: Whether to show server records or not. - :type show_server_records: bool - """ - - _attribute_map = { - 'event_time': {'key': 'eventTime', 'type': 'iso-8601'}, - 'show_server_records': {'key': 'showServerRecords', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SecurityEventsFilterParameters, self).__init__(**kwargs) - self.event_time = kwargs.get('event_time', None) - self.show_server_records = kwargs.get('show_server_records', None) - - -class SecurityEventSqlInjectionAdditionalProperties(msrest.serialization.Model): - """The properties of a security event sql injection additional properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar threat_id: The threat ID. - :vartype threat_id: str - :ivar statement: The statement. - :vartype statement: str - :ivar statement_highlight_offset: The statement highlight offset. - :vartype statement_highlight_offset: int - :ivar statement_highlight_length: The statement highlight length. - :vartype statement_highlight_length: int - :ivar error_code: The sql error code. - :vartype error_code: int - :ivar error_severity: The sql error severity. - :vartype error_severity: int - :ivar error_message: The sql error message. - :vartype error_message: str - """ - - _validation = { - 'threat_id': {'readonly': True}, - 'statement': {'readonly': True}, - 'statement_highlight_offset': {'readonly': True}, - 'statement_highlight_length': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'error_message': {'readonly': True}, - } - - _attribute_map = { - 'threat_id': {'key': 'threatId', 'type': 'str'}, - 'statement': {'key': 'statement', 'type': 'str'}, - 'statement_highlight_offset': {'key': 'statementHighlightOffset', 'type': 'int'}, - 'statement_highlight_length': {'key': 'statementHighlightLength', 'type': 'int'}, - 'error_code': {'key': 'errorCode', 'type': 'int'}, - 'error_severity': {'key': 'errorSeverity', 'type': 'int'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SecurityEventSqlInjectionAdditionalProperties, self).__init__(**kwargs) - self.threat_id = None - self.statement = None - self.statement_highlight_offset = None - self.statement_highlight_length = None - self.error_code = None - self.error_severity = None - self.error_message = None - - -class SensitivityLabel(ProxyResource): - """A sensitivity label. - - 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 managed_by: Resource that manages the sensitivity label. - :vartype managed_by: str - :ivar schema_name: The schema name. - :vartype schema_name: str - :ivar table_name: The table name. - :vartype table_name: str - :ivar column_name: The column name. - :vartype column_name: str - :param label_name: The label name. - :type label_name: str - :param label_id: The label ID. - :type label_id: str - :param information_type: The information type. - :type information_type: str - :param information_type_id: The information type ID. - :type information_type_id: str - :ivar is_disabled: Is sensitivity recommendation disabled. Applicable for recommended - sensitivity label only. Specifies whether the sensitivity recommendation on this column is - disabled (dismissed) or not. - :vartype is_disabled: bool - :param rank: Possible values include: "None", "Low", "Medium", "High", "Critical". - :type rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'managed_by': {'readonly': True}, - 'schema_name': {'readonly': True}, - 'table_name': {'readonly': True}, - 'column_name': {'readonly': True}, - 'is_disabled': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'schema_name': {'key': 'properties.schemaName', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'column_name': {'key': 'properties.columnName', 'type': 'str'}, - 'label_name': {'key': 'properties.labelName', 'type': 'str'}, - 'label_id': {'key': 'properties.labelId', 'type': 'str'}, - 'information_type': {'key': 'properties.informationType', 'type': 'str'}, - 'information_type_id': {'key': 'properties.informationTypeId', 'type': 'str'}, - 'is_disabled': {'key': 'properties.isDisabled', 'type': 'bool'}, - 'rank': {'key': 'properties.rank', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SensitivityLabel, self).__init__(**kwargs) - self.managed_by = None - self.schema_name = None - self.table_name = None - self.column_name = None - self.label_name = kwargs.get('label_name', None) - self.label_id = kwargs.get('label_id', None) - self.information_type = kwargs.get('information_type', None) - self.information_type_id = kwargs.get('information_type_id', None) - self.is_disabled = None - self.rank = kwargs.get('rank', None) - - -class SensitivityLabelListResult(msrest.serialization.Model): - """A list of sensitivity labels. - - 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.SensitivityLabel] - :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': '[SensitivityLabel]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SensitivityLabelListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SensitivityLabelUpdate(ProxyResource): - """A sensitivity label update operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param op: Possible values include: "set", "remove". - :type op: str or ~azure.mgmt.sql.models.SensitivityLabelUpdateKind - :param schema: Schema name of the column to update. - :type schema: str - :param table: Table name of the column to update. - :type table: str - :param column: Column name to update. - :type column: str - :param sensitivity_label: The sensitivity label information to apply on a column. - :type sensitivity_label: ~azure.mgmt.sql.models.SensitivityLabel - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'op': {'key': 'properties.op', 'type': 'str'}, - 'schema': {'key': 'properties.schema', 'type': 'str'}, - 'table': {'key': 'properties.table', 'type': 'str'}, - 'column': {'key': 'properties.column', 'type': 'str'}, - 'sensitivity_label': {'key': 'properties.sensitivityLabel', 'type': 'SensitivityLabel'}, - } - - def __init__( - self, - **kwargs - ): - super(SensitivityLabelUpdate, self).__init__(**kwargs) - self.op = kwargs.get('op', None) - self.schema = kwargs.get('schema', None) - self.table = kwargs.get('table', None) - self.column = kwargs.get('column', None) - self.sensitivity_label = kwargs.get('sensitivity_label', None) - - -class SensitivityLabelUpdateList(msrest.serialization.Model): - """A list of sensitivity label update operations. - - :param operations: - :type operations: list[~azure.mgmt.sql.models.SensitivityLabelUpdate] - """ - - _attribute_map = { - 'operations': {'key': 'operations', 'type': '[SensitivityLabelUpdate]'}, - } - - def __init__( - self, - **kwargs - ): - super(SensitivityLabelUpdateList, self).__init__(**kwargs) - self.operations = kwargs.get('operations', None) - - -class Server(TrackedResource): - """An Azure SQL Database server. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: The Azure Active Directory identity of the server. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity - :ivar kind: Kind of sql server. This is metadata used for the Azure portal experience. - :vartype kind: str - :param administrator_login: Administrator username for the server. Once created it cannot be - changed. - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for server - creation). - :type administrator_login_password: str - :param version: The version of the server. - :type version: str - :ivar state: The state of the server. - :vartype state: str - :ivar fully_qualified_domain_name: The fully qualified domain name of the server. - :vartype fully_qualified_domain_name: str - :ivar private_endpoint_connections: List of private endpoint connections on a server. - :vartype private_endpoint_connections: - list[~azure.mgmt.sql.models.ServerPrivateEndpointConnection] - :param minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. - :type minimal_tls_version: str - :param public_network_access: Whether or not public endpoint access is allowed for this server. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :ivar workspace_feature: Whether or not existing server has a workspace created and if it - allows connection from workspace. Possible values include: "Connected", "Disconnected". - :vartype workspace_feature: str or ~azure.mgmt.sql.models.ServerWorkspaceFeature - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param federated_client_id: The Client id used for cross tenant CMK scenario. - :type federated_client_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory identity of the server. - :type administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :param restrict_outbound_network_access: Whether or not to restrict outbound network access for - this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible - values include: "Enabled", "Disabled". - :type restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'state': {'readonly': True}, - 'fully_qualified_domain_name': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'workspace_feature': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'administrator_login': {'key': 'properties.administratorLogin', 'type': 'str'}, - 'administrator_login_password': {'key': 'properties.administratorLoginPassword', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'fully_qualified_domain_name': {'key': 'properties.fullyQualifiedDomainName', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[ServerPrivateEndpointConnection]'}, - 'minimal_tls_version': {'key': 'properties.minimalTlsVersion', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'workspace_feature': {'key': 'properties.workspaceFeature', 'type': 'str'}, - 'primary_user_assigned_identity_id': {'key': 'properties.primaryUserAssignedIdentityId', 'type': 'str'}, - 'federated_client_id': {'key': 'properties.federatedClientId', 'type': 'str'}, - 'key_id': {'key': 'properties.keyId', 'type': 'str'}, - 'administrators': {'key': 'properties.administrators', 'type': 'ServerExternalAdministrator'}, - 'restrict_outbound_network_access': {'key': 'properties.restrictOutboundNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Server, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.kind = None - self.administrator_login = kwargs.get('administrator_login', None) - self.administrator_login_password = kwargs.get('administrator_login_password', None) - self.version = kwargs.get('version', None) - self.state = None - self.fully_qualified_domain_name = None - self.private_endpoint_connections = None - self.minimal_tls_version = kwargs.get('minimal_tls_version', None) - self.public_network_access = kwargs.get('public_network_access', None) - self.workspace_feature = None - self.primary_user_assigned_identity_id = kwargs.get('primary_user_assigned_identity_id', None) - self.federated_client_id = kwargs.get('federated_client_id', None) - self.key_id = kwargs.get('key_id', None) - self.administrators = kwargs.get('administrators', None) - self.restrict_outbound_network_access = kwargs.get('restrict_outbound_network_access', None) - - -class ServerAutomaticTuning(ProxyResource): - """Server-level Automatic Tuning. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param desired_state: Automatic tuning desired state. Possible values include: "Custom", - "Auto", "Unspecified". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode - :ivar actual_state: Automatic tuning actual state. Possible values include: "Custom", "Auto", - "Unspecified". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode - :param options: Automatic tuning options definition. - :type options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningServerOptions] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'actual_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'desired_state': {'key': 'properties.desiredState', 'type': 'str'}, - 'actual_state': {'key': 'properties.actualState', 'type': 'str'}, - 'options': {'key': 'properties.options', 'type': '{AutomaticTuningServerOptions}'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerAutomaticTuning, self).__init__(**kwargs) - self.desired_state = kwargs.get('desired_state', None) - self.actual_state = None - self.options = kwargs.get('options', None) - - -class ServerAzureADAdministrator(ProxyResource): - """Azure Active Directory administrator. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param administrator_type: Type of the sever administrator. Possible values include: - "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :param login: Login name of the server administrator. - :type login: str - :param sid: SID (object ID) of the server administrator. - :type sid: str - :param tenant_id: Tenant ID of the administrator. - :type tenant_id: str - :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :vartype azure_ad_only_authentication: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'azure_ad_only_authentication': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'administrator_type': {'key': 'properties.administratorType', 'type': 'str'}, - 'login': {'key': 'properties.login', 'type': 'str'}, - 'sid': {'key': 'properties.sid', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'azure_ad_only_authentication': {'key': 'properties.azureADOnlyAuthentication', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerAzureADAdministrator, self).__init__(**kwargs) - self.administrator_type = kwargs.get('administrator_type', None) - self.login = kwargs.get('login', None) - self.sid = kwargs.get('sid', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.azure_ad_only_authentication = None - - -class ServerAzureADOnlyAuthentication(ProxyResource): - """Azure Active Directory only authentication. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'azure_ad_only_authentication': {'key': 'properties.azureADOnlyAuthentication', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerAzureADOnlyAuthentication, self).__init__(**kwargs) - self.azure_ad_only_authentication = kwargs.get('azure_ad_only_authentication', None) - - -class ServerBlobAuditingPolicy(ProxyResource): - """A server blob auditing policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, - devops logs will be sent to Azure Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled', - 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - - When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should also be created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :type is_devops_audit_enabled: bool - :param retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_devops_audit_enabled': {'key': 'properties.isDevopsAuditEnabled', 'type': 'bool'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'queue_delay_ms': {'key': 'properties.queueDelayMs', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerBlobAuditingPolicy, self).__init__(**kwargs) - self.is_devops_audit_enabled = kwargs.get('is_devops_audit_enabled', None) - self.retention_days = kwargs.get('retention_days', None) - self.audit_actions_and_groups = kwargs.get('audit_actions_and_groups', None) - self.is_storage_secondary_key_in_use = kwargs.get('is_storage_secondary_key_in_use', None) - self.is_azure_monitor_target_enabled = kwargs.get('is_azure_monitor_target_enabled', None) - self.queue_delay_ms = kwargs.get('queue_delay_ms', None) - self.state = kwargs.get('state', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.storage_account_subscription_id = kwargs.get('storage_account_subscription_id', None) - - -class ServerBlobAuditingPolicyListResult(msrest.serialization.Model): - """A list of server auditing 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.ServerBlobAuditingPolicy] - :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': '[ServerBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerBlobAuditingPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerCommunicationLink(ProxyResource): - """Server communication link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Communication link location. - :vartype location: str - :ivar kind: Communication link kind. This property is used for Azure Portal metadata. - :vartype kind: str - :ivar state: The state. - :vartype state: str - :param partner_server: The name of the partner server. - :type partner_server: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'kind': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'partner_server': {'key': 'properties.partnerServer', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerCommunicationLink, self).__init__(**kwargs) - self.location = None - self.kind = None - self.state = None - self.partner_server = kwargs.get('partner_server', None) - - -class ServerCommunicationLinkListResult(msrest.serialization.Model): - """A list of server communication links. - - :param value: The list of server communication links. - :type value: list[~azure.mgmt.sql.models.ServerCommunicationLink] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerCommunicationLink]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerCommunicationLinkListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ServerConnectionPolicy(ProxyResource): - """A server connection policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar kind: Metadata used for the Azure portal experience. - :vartype kind: str - :param connection_type: The server connection type. Possible values include: "Default", - "Redirect", "Proxy". - :type connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'kind': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'connection_type': {'key': 'properties.connectionType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerConnectionPolicy, self).__init__(**kwargs) - self.location = None - self.kind = None - self.connection_type = kwargs.get('connection_type', None) - - -class ServerConnectionPolicyListResult(msrest.serialization.Model): - """A list of server connection policy objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerConnectionPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerConnectionPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerConnectionPolicyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerDevOpsAuditingSettings(ProxyResource): - """A server DevOps auditing settings. - - 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 ServerDevOpsAuditSettingsResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param is_azure_monitor_target_enabled: Specifies whether DevOps audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure DevOps audit, Diagnostic Settings with - 'DevOpsOperationsAudit' diagnostic logs category on the master database should be also created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'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'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerDevOpsAuditingSettings, self).__init__(**kwargs) - self.system_data = None - self.is_azure_monitor_target_enabled = kwargs.get('is_azure_monitor_target_enabled', None) - self.state = kwargs.get('state', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.storage_account_subscription_id = kwargs.get('storage_account_subscription_id', None) - - -class ServerDevOpsAuditSettingsListResult(msrest.serialization.Model): - """A list of server DevOps audit 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.ServerDevOpsAuditingSettings] - :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': '[ServerDevOpsAuditingSettings]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerDevOpsAuditSettingsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerDnsAlias(ProxyResource): - """A server DNS alias. - - 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 azure_dns_record: The fully qualified DNS record for alias. - :vartype azure_dns_record: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'azure_dns_record': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'azure_dns_record': {'key': 'properties.azureDnsRecord', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerDnsAlias, self).__init__(**kwargs) - self.azure_dns_record = None - - -class ServerDnsAliasAcquisition(msrest.serialization.Model): - """A server dns alias acquisition request. - - All required parameters must be populated in order to send to Azure. - - :param old_server_dns_alias_id: Required. The id of the server alias that will be acquired to - point to this server instead. - :type old_server_dns_alias_id: str - """ - - _validation = { - 'old_server_dns_alias_id': {'required': True}, - } - - _attribute_map = { - 'old_server_dns_alias_id': {'key': 'oldServerDnsAliasId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerDnsAliasAcquisition, self).__init__(**kwargs) - self.old_server_dns_alias_id = kwargs['old_server_dns_alias_id'] - - -class ServerDnsAliasListResult(msrest.serialization.Model): - """A list of server DNS aliases. - - 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.ServerDnsAlias] - :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': '[ServerDnsAlias]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerDnsAliasListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerExternalAdministrator(msrest.serialization.Model): - """Properties of a active directory administrator. - - :param administrator_type: Type of the sever administrator. Possible values include: - "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :param principal_type: Principal Type of the sever administrator. Possible values include: - "User", "Group", "Application". - :type principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :param login: Login name of the server administrator. - :type login: str - :param sid: SID (object ID) of the server administrator. - :type sid: str - :param tenant_id: Tenant ID of the administrator. - :type tenant_id: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool - """ - - _attribute_map = { - 'administrator_type': {'key': 'administratorType', 'type': 'str'}, - 'principal_type': {'key': 'principalType', 'type': 'str'}, - 'login': {'key': 'login', 'type': 'str'}, - 'sid': {'key': 'sid', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'azure_ad_only_authentication': {'key': 'azureADOnlyAuthentication', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerExternalAdministrator, self).__init__(**kwargs) - self.administrator_type = kwargs.get('administrator_type', None) - self.principal_type = kwargs.get('principal_type', None) - self.login = kwargs.get('login', None) - self.sid = kwargs.get('sid', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.azure_ad_only_authentication = kwargs.get('azure_ad_only_authentication', None) - - -class ServerInfo(msrest.serialization.Model): - """Server info for the server trust group. - - All required parameters must be populated in order to send to Azure. - - :param server_id: Required. Server Id. - :type server_id: str - """ - - _validation = { - 'server_id': {'required': True}, - } - - _attribute_map = { - 'server_id': {'key': 'serverId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerInfo, self).__init__(**kwargs) - self.server_id = kwargs['server_id'] - - -class ServerKey(ProxyResource): - """A server key. - - 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 kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar subregion: Subregion of the server key. - :vartype subregion: str - :param server_key_type: The server key type like 'ServiceManaged', 'AzureKeyVault'. Possible - values include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :param uri: The URI of the server key. If the ServerKeyType is AzureKeyVault, then the URI is - required. - :type uri: str - :ivar thumbprint: Thumbprint of the server key. - :vartype thumbprint: str - :ivar creation_date: The server key creation date. - :vartype creation_date: ~datetime.datetime - :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :vartype auto_rotation_enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, - 'subregion': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'auto_rotation_enabled': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'subregion': {'key': 'properties.subregion', 'type': 'str'}, - 'server_key_type': {'key': 'properties.serverKeyType', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'auto_rotation_enabled': {'key': 'properties.autoRotationEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerKey, self).__init__(**kwargs) - self.kind = None - self.location = None - self.subregion = None - self.server_key_type = kwargs.get('server_key_type', None) - self.uri = kwargs.get('uri', None) - self.thumbprint = None - self.creation_date = None - self.auto_rotation_enabled = None - - -class ServerKeyListResult(msrest.serialization.Model): - """A list of server keys. - - 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.ServerKey] - :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': '[ServerKey]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerKeyListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerListResult(msrest.serialization.Model): - """A list of servers. - - 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.Server] - :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': '[Server]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerOperation(ProxyResource): - """A server operation. - - 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 operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar server_name: The name of the server. - :vartype server_name: str - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Possible values include: "Pending", "InProgress", - "Succeeded", "Failed", "CancelInProgress", "Cancelled". - :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'operation': {'readonly': True}, - 'operation_friendly_name': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'server_name': {'readonly': True}, - 'start_time': {'readonly': True}, - 'state': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_description': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'is_user_error': {'readonly': True}, - 'estimated_completion_time': {'readonly': True}, - 'description': {'readonly': True}, - 'is_cancellable': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'operation_friendly_name': {'key': 'properties.operationFriendlyName', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, - 'error_description': {'key': 'properties.errorDescription', 'type': 'str'}, - 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, - 'is_user_error': {'key': 'properties.isUserError', 'type': 'bool'}, - 'estimated_completion_time': {'key': 'properties.estimatedCompletionTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_cancellable': {'key': 'properties.isCancellable', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerOperation, self).__init__(**kwargs) - self.operation = None - self.operation_friendly_name = None - self.percent_complete = None - self.server_name = None - self.start_time = None - self.state = None - self.error_code = None - self.error_description = None - self.error_severity = None - self.is_user_error = None - self.estimated_completion_time = None - self.description = None - self.is_cancellable = None - - -class ServerOperationListResult(msrest.serialization.Model): - """The response to a list server operations request. - - 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.ServerOperation] - :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': '[ServerOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerOperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerPrivateEndpointConnection(msrest.serialization.Model): - """A private endpoint connection under a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar properties: Private endpoint connection properties. - :vartype properties: ~azure.mgmt.sql.models.PrivateEndpointConnectionProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerPrivateEndpointConnection, self).__init__(**kwargs) - self.id = None - self.properties = None - - -class ServerSecurityAlertPolicy(ProxyResource): - """A server security alert policy. - - 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 SecurityAlertPolicyResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Possible values include: "Enabled", - "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int - :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'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerSecurityAlertPolicy, self).__init__(**kwargs) - self.system_data = None - self.state = kwargs.get('state', None) - self.disabled_alerts = kwargs.get('disabled_alerts', None) - self.email_addresses = kwargs.get('email_addresses', None) - self.email_account_admins = kwargs.get('email_account_admins', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.retention_days = kwargs.get('retention_days', None) - self.creation_time = None - - -class ServerTrustGroup(ProxyResource): - """A server trust group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param group_members: Group members information for the server trust group. - :type group_members: list[~azure.mgmt.sql.models.ServerInfo] - :param trust_scopes: Trust scope of the server trust group. - :type trust_scopes: list[str or - ~azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_members': {'key': 'properties.groupMembers', 'type': '[ServerInfo]'}, - 'trust_scopes': {'key': 'properties.trustScopes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerTrustGroup, self).__init__(**kwargs) - self.group_members = kwargs.get('group_members', None) - self.trust_scopes = kwargs.get('trust_scopes', None) - - -class ServerTrustGroupListResult(msrest.serialization.Model): - """A list of server trust groups. - - 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.ServerTrustGroup] - :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': '[ServerTrustGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerTrustGroupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerUpdate(msrest.serialization.Model): - """An update request for an Azure SQL Database server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param identity: Server identity. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param administrator_login: Administrator username for the server. Once created it cannot be - changed. - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for server - creation). - :type administrator_login_password: str - :param version: The version of the server. - :type version: str - :ivar state: The state of the server. - :vartype state: str - :ivar fully_qualified_domain_name: The fully qualified domain name of the server. - :vartype fully_qualified_domain_name: str - :ivar private_endpoint_connections: List of private endpoint connections on a server. - :vartype private_endpoint_connections: - list[~azure.mgmt.sql.models.ServerPrivateEndpointConnection] - :param minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. - :type minimal_tls_version: str - :param public_network_access: Whether or not public endpoint access is allowed for this server. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :ivar workspace_feature: Whether or not existing server has a workspace created and if it - allows connection from workspace. Possible values include: "Connected", "Disconnected". - :vartype workspace_feature: str or ~azure.mgmt.sql.models.ServerWorkspaceFeature - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param federated_client_id: The Client id used for cross tenant CMK scenario. - :type federated_client_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory identity of the server. - :type administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :param restrict_outbound_network_access: Whether or not to restrict outbound network access for - this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible - values include: "Enabled", "Disabled". - :type restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - """ - - _validation = { - 'state': {'readonly': True}, - 'fully_qualified_domain_name': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'workspace_feature': {'readonly': True}, - } - - _attribute_map = { - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'administrator_login': {'key': 'properties.administratorLogin', 'type': 'str'}, - 'administrator_login_password': {'key': 'properties.administratorLoginPassword', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'fully_qualified_domain_name': {'key': 'properties.fullyQualifiedDomainName', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[ServerPrivateEndpointConnection]'}, - 'minimal_tls_version': {'key': 'properties.minimalTlsVersion', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'workspace_feature': {'key': 'properties.workspaceFeature', 'type': 'str'}, - 'primary_user_assigned_identity_id': {'key': 'properties.primaryUserAssignedIdentityId', 'type': 'str'}, - 'federated_client_id': {'key': 'properties.federatedClientId', 'type': 'str'}, - 'key_id': {'key': 'properties.keyId', 'type': 'str'}, - 'administrators': {'key': 'properties.administrators', 'type': 'ServerExternalAdministrator'}, - 'restrict_outbound_network_access': {'key': 'properties.restrictOutboundNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerUpdate, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.tags = kwargs.get('tags', None) - self.administrator_login = kwargs.get('administrator_login', None) - self.administrator_login_password = kwargs.get('administrator_login_password', None) - self.version = kwargs.get('version', None) - self.state = None - self.fully_qualified_domain_name = None - self.private_endpoint_connections = None - self.minimal_tls_version = kwargs.get('minimal_tls_version', None) - self.public_network_access = kwargs.get('public_network_access', None) - self.workspace_feature = None - self.primary_user_assigned_identity_id = kwargs.get('primary_user_assigned_identity_id', None) - self.federated_client_id = kwargs.get('federated_client_id', None) - self.key_id = kwargs.get('key_id', None) - self.administrators = kwargs.get('administrators', None) - self.restrict_outbound_network_access = kwargs.get('restrict_outbound_network_access', None) - - -class ServerUsage(msrest.serialization.Model): - """Represents server metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the server usage metric. - :vartype name: str - :ivar resource_name: The name of the resource. - :vartype resource_name: str - :ivar display_name: The metric display name. - :vartype display_name: str - :ivar current_value: The current value of the metric. - :vartype current_value: float - :ivar limit: The current limit of the metric. - :vartype limit: float - :ivar unit: The units of the metric. - :vartype unit: str - :ivar next_reset_time: The next reset time for the metric (ISO8601 format). - :vartype next_reset_time: ~datetime.datetime - """ - - _validation = { - 'name': {'readonly': True}, - 'resource_name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - 'next_reset_time': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'float'}, - 'limit': {'key': 'limit', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'next_reset_time': {'key': 'nextResetTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerUsage, self).__init__(**kwargs) - self.name = None - self.resource_name = None - self.display_name = None - self.current_value = None - self.limit = None - self.unit = None - self.next_reset_time = None - - -class ServerUsageListResult(msrest.serialization.Model): - """Represents the response to a list server metrics request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of server metrics for the server. - :type value: list[~azure.mgmt.sql.models.ServerUsage] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerUsage]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerUsageListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class ServerVersionCapability(msrest.serialization.Model): - """The server capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The server version name. - :vartype name: str - :ivar supported_editions: The list of supported database editions. - :vartype supported_editions: list[~azure.mgmt.sql.models.EditionCapability] - :ivar supported_elastic_pool_editions: The list of supported elastic pool editions. - :vartype supported_elastic_pool_editions: - list[~azure.mgmt.sql.models.ElasticPoolEditionCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'name': {'readonly': True}, - 'supported_editions': {'readonly': True}, - 'supported_elastic_pool_editions': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'supported_editions': {'key': 'supportedEditions', 'type': '[EditionCapability]'}, - 'supported_elastic_pool_editions': {'key': 'supportedElasticPoolEditions', 'type': '[ElasticPoolEditionCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerVersionCapability, self).__init__(**kwargs) - self.name = None - self.supported_editions = None - self.supported_elastic_pool_editions = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ServerVulnerabilityAssessment(ProxyResource): - """A server vulnerability assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). - :type storage_container_path: str - :param storage_container_sas_key: A shared access signature (SAS Key) that has write access to - the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' - isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not - behind a Vnet or a firewall. - :type storage_container_sas_key: str - :param storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet - or a firewall. - :type storage_account_access_key: str - :param recurring_scans: The recurring scans settings. - :type recurring_scans: ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_container_path': {'key': 'properties.storageContainerPath', 'type': 'str'}, - 'storage_container_sas_key': {'key': 'properties.storageContainerSasKey', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'recurring_scans': {'key': 'properties.recurringScans', 'type': 'VulnerabilityAssessmentRecurringScansProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerVulnerabilityAssessment, self).__init__(**kwargs) - self.storage_container_path = kwargs.get('storage_container_path', None) - self.storage_container_sas_key = kwargs.get('storage_container_sas_key', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.recurring_scans = kwargs.get('recurring_scans', None) - - -class ServerVulnerabilityAssessmentListResult(msrest.serialization.Model): - """A list of the server's vulnerability assessments. - - 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.ServerVulnerabilityAssessment] - :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': '[ServerVulnerabilityAssessment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerVulnerabilityAssessmentListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServiceObjective(ProxyResource): - """Represents a database service objective. - - 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 service_objective_name: The name for the service objective. - :vartype service_objective_name: str - :ivar is_default: Gets whether the service level objective is the default service objective. - :vartype is_default: bool - :ivar is_system: Gets whether the service level objective is a system service objective. - :vartype is_system: bool - :ivar description: The description for the service level objective. - :vartype description: str - :ivar enabled: Gets whether the service level objective is enabled. - :vartype enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'service_objective_name': {'readonly': True}, - 'is_default': {'readonly': True}, - 'is_system': {'readonly': True}, - 'description': {'readonly': True}, - 'enabled': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'service_objective_name': {'key': 'properties.serviceObjectiveName', 'type': 'str'}, - 'is_default': {'key': 'properties.isDefault', 'type': 'bool'}, - 'is_system': {'key': 'properties.isSystem', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceObjective, self).__init__(**kwargs) - self.service_objective_name = None - self.is_default = None - self.is_system = None - self.description = None - self.enabled = None - - -class ServiceObjectiveCapability(msrest.serialization.Model): - """The service objectives capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The unique ID of the service objective. - :vartype id: str - :ivar name: The service objective name. - :vartype name: str - :ivar supported_max_sizes: The list of supported maximum database sizes. - :vartype supported_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar performance_level: The performance level. - :vartype performance_level: ~azure.mgmt.sql.models.PerformanceLevelCapability - :ivar sku: The sku. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar included_max_size: The included (free) max size. - :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar zone_redundant: Whether or not zone redundancy is supported for the service objective. - :vartype zone_redundant: bool - :ivar supported_auto_pause_delay: Supported time range for auto pause delay. - :vartype supported_auto_pause_delay: ~azure.mgmt.sql.models.AutoPauseDelayTimeRange - :ivar supported_min_capacities: List of supported min capacities. - :vartype supported_min_capacities: list[~azure.mgmt.sql.models.MinCapacityCapability] - :ivar compute_model: The compute model. - :vartype compute_model: str - :ivar supported_maintenance_configurations: List of supported maintenance configurations. - :vartype supported_maintenance_configurations: - list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'supported_max_sizes': {'readonly': True}, - 'performance_level': {'readonly': True}, - 'sku': {'readonly': True}, - 'supported_license_types': {'readonly': True}, - 'included_max_size': {'readonly': True}, - 'zone_redundant': {'readonly': True}, - 'supported_auto_pause_delay': {'readonly': True}, - 'supported_min_capacities': {'readonly': True}, - 'compute_model': {'readonly': True}, - 'supported_maintenance_configurations': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'supported_max_sizes': {'key': 'supportedMaxSizes', 'type': '[MaxSizeRangeCapability]'}, - 'performance_level': {'key': 'performanceLevel', 'type': 'PerformanceLevelCapability'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'supported_license_types': {'key': 'supportedLicenseTypes', 'type': '[LicenseTypeCapability]'}, - 'included_max_size': {'key': 'includedMaxSize', 'type': 'MaxSizeCapability'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'supported_auto_pause_delay': {'key': 'supportedAutoPauseDelay', 'type': 'AutoPauseDelayTimeRange'}, - 'supported_min_capacities': {'key': 'supportedMinCapacities', 'type': '[MinCapacityCapability]'}, - 'compute_model': {'key': 'computeModel', 'type': 'str'}, - 'supported_maintenance_configurations': {'key': 'supportedMaintenanceConfigurations', 'type': '[MaintenanceConfigurationCapability]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceObjectiveCapability, self).__init__(**kwargs) - self.id = None - self.name = None - self.supported_max_sizes = None - self.performance_level = None - self.sku = None - self.supported_license_types = None - self.included_max_size = None - self.zone_redundant = None - self.supported_auto_pause_delay = None - self.supported_min_capacities = None - self.compute_model = None - self.supported_maintenance_configurations = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class ServiceObjectiveListResult(msrest.serialization.Model): - """Represents the response to a get database service objectives request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of database service objectives. - :type value: list[~azure.mgmt.sql.models.ServiceObjective] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceObjective]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceObjectiveListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class ServicePrincipal(msrest.serialization.Model): - """The managed instance's service principal configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The Azure Active Directory application object id. - :vartype principal_id: str - :ivar client_id: The Azure Active Directory application client id. - :vartype client_id: str - :ivar tenant_id: The Azure Active Directory tenant id. - :vartype tenant_id: str - :param type: Service principal type. Possible values include: "None", "SystemAssigned". - :type type: str or ~azure.mgmt.sql.models.ServicePrincipalType - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServicePrincipal, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - - -class Sku(msrest.serialization.Model): - """An ARM Resource SKU. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU, typically, a letter + Number code, e.g. P3. - :type name: str - :param tier: The tier or edition of the particular SKU, e.g. Basic, Premium. - :type tier: str - :param size: Size of the particular SKU. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param capacity: Capacity of the particular SKU. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.size = kwargs.get('size', None) - self.family = kwargs.get('family', None) - self.capacity = kwargs.get('capacity', None) - - -class SloUsageMetric(msrest.serialization.Model): - """A Slo Usage Metric. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar service_level_objective: The serviceLevelObjective for SLO usage metric. Possible values - include: "System", "System0", "System1", "System2", "System3", "System4", "System2L", - "System3L", "System4L", "Free", "Basic", "S0", "S1", "S2", "S3", "S4", "S6", "S7", "S9", "S12", - "P1", "P2", "P3", "P4", "P6", "P11", "P15", "PRS1", "PRS2", "PRS4", "PRS6", "DW100", "DW200", - "DW300", "DW400", "DW500", "DW600", "DW1000", "DW1200", "DW1000c", "DW1500", "DW1500c", - "DW2000", "DW2000c", "DW3000", "DW2500c", "DW3000c", "DW6000", "DW5000c", "DW6000c", "DW7500c", - "DW10000c", "DW15000c", "DW30000c", "DS100", "DS200", "DS300", "DS400", "DS500", "DS600", - "DS1000", "DS1200", "DS1500", "DS2000", "ElasticPool". - :vartype service_level_objective: str or ~azure.mgmt.sql.models.ServiceObjectiveName - :ivar service_level_objective_id: The serviceLevelObjectiveId for SLO usage metric. - :vartype service_level_objective_id: str - :ivar in_range_time_ratio: Gets or sets inRangeTimeRatio for SLO usage metric. - :vartype in_range_time_ratio: float - """ - - _validation = { - 'service_level_objective': {'readonly': True}, - 'service_level_objective_id': {'readonly': True}, - 'in_range_time_ratio': {'readonly': True}, - } - - _attribute_map = { - 'service_level_objective': {'key': 'serviceLevelObjective', 'type': 'str'}, - 'service_level_objective_id': {'key': 'serviceLevelObjectiveId', 'type': 'str'}, - 'in_range_time_ratio': {'key': 'inRangeTimeRatio', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(SloUsageMetric, self).__init__(**kwargs) - self.service_level_objective = None - self.service_level_objective_id = None - self.in_range_time_ratio = None - - -class SqlAgentConfiguration(ProxyResource): - """A recoverable managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param state: The state of Sql Agent. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlAgentConfiguration, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - - -class StorageCapability(msrest.serialization.Model): - """The storage account type capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar storage_account_type: The storage account type for the database's backups. Possible - values include: "GRS", "LRS", "ZRS". - :vartype storage_account_type: str or - ~azure.mgmt.sql.models.StorageCapabilityStorageAccountType - :ivar status: The status of the capability. Possible values include: "Visible", "Available", - "Default", "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str - """ - - _validation = { - 'storage_account_type': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'storage_account_type': {'key': 'storageAccountType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageCapability, self).__init__(**kwargs) - self.storage_account_type = None - self.status = None - self.reason = kwargs.get('reason', None) - - -class SubscriptionUsage(ProxyResource): - """Usage Metric of a Subscription in a Location. - - 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 display_name: User-readable name of the metric. - :vartype display_name: str - :ivar current_value: Current value of the metric. - :vartype current_value: float - :ivar limit: Boundary value of the metric. - :vartype limit: float - :ivar unit: Unit of the metric. - :vartype unit: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'current_value': {'key': 'properties.currentValue', 'type': 'float'}, - 'limit': {'key': 'properties.limit', 'type': 'float'}, - 'unit': {'key': 'properties.unit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionUsage, self).__init__(**kwargs) - self.display_name = None - self.current_value = None - self.limit = None - self.unit = None - - -class SubscriptionUsageListResult(msrest.serialization.Model): - """A list of subscription usage metrics in a location. - - 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.SubscriptionUsage] - :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': '[SubscriptionUsage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionUsageListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SyncAgent(ProxyResource): - """An Azure SQL Database sync agent. - - 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 name_properties_name: Name of the sync agent. - :vartype name_properties_name: str - :param sync_database_id: ARM resource id of the sync database in the sync agent. - :type sync_database_id: str - :ivar last_alive_time: Last alive time of the sync agent. - :vartype last_alive_time: ~datetime.datetime - :ivar state: State of the sync agent. Possible values include: "Online", "Offline", - "NeverConnected". - :vartype state: str or ~azure.mgmt.sql.models.SyncAgentState - :ivar is_up_to_date: If the sync agent version is up to date. - :vartype is_up_to_date: bool - :ivar expiry_time: Expiration time of the sync agent version. - :vartype expiry_time: ~datetime.datetime - :ivar version: Version of the sync agent. - :vartype version: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'name_properties_name': {'readonly': True}, - 'last_alive_time': {'readonly': True}, - 'state': {'readonly': True}, - 'is_up_to_date': {'readonly': True}, - 'expiry_time': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'sync_database_id': {'key': 'properties.syncDatabaseId', 'type': 'str'}, - 'last_alive_time': {'key': 'properties.lastAliveTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'is_up_to_date': {'key': 'properties.isUpToDate', 'type': 'bool'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncAgent, self).__init__(**kwargs) - self.name_properties_name = None - self.sync_database_id = kwargs.get('sync_database_id', None) - self.last_alive_time = None - self.state = None - self.is_up_to_date = None - self.expiry_time = None - self.version = None - - -class SyncAgentKeyProperties(msrest.serialization.Model): - """Properties of an Azure SQL Database sync agent key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar sync_agent_key: Key of sync agent. - :vartype sync_agent_key: str - """ - - _validation = { - 'sync_agent_key': {'readonly': True}, - } - - _attribute_map = { - 'sync_agent_key': {'key': 'syncAgentKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncAgentKeyProperties, self).__init__(**kwargs) - self.sync_agent_key = None - - -class SyncAgentLinkedDatabase(ProxyResource): - """An Azure SQL Database sync agent linked database. - - 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 database_type: Type of the sync agent linked database. Possible values include: - "AzureSqlDatabase", "SqlServerDatabase". - :vartype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType - :ivar database_id: Id of the sync agent linked database. - :vartype database_id: str - :ivar description: Description of the sync agent linked database. - :vartype description: str - :ivar server_name: Server name of the sync agent linked database. - :vartype server_name: str - :ivar database_name: Database name of the sync agent linked database. - :vartype database_name: str - :ivar user_name: User name of the sync agent linked database. - :vartype user_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'database_type': {'readonly': True}, - 'database_id': {'readonly': True}, - 'description': {'readonly': True}, - 'server_name': {'readonly': True}, - 'database_name': {'readonly': True}, - 'user_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_type': {'key': 'properties.databaseType', 'type': 'str'}, - 'database_id': {'key': 'properties.databaseId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncAgentLinkedDatabase, self).__init__(**kwargs) - self.database_type = None - self.database_id = None - self.description = None - self.server_name = None - self.database_name = None - self.user_name = None - - -class SyncAgentLinkedDatabaseListResult(msrest.serialization.Model): - """A list of sync agent linked databases. - - 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.SyncAgentLinkedDatabase] - :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': '[SyncAgentLinkedDatabase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncAgentLinkedDatabaseListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SyncAgentListResult(msrest.serialization.Model): - """A list of sync agents. - - 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.SyncAgent] - :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': '[SyncAgent]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncAgentListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SyncDatabaseIdListResult(msrest.serialization.Model): - """A list of sync database ID properties. - - 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.SyncDatabaseIdProperties] - :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': '[SyncDatabaseIdProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncDatabaseIdListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SyncDatabaseIdProperties(msrest.serialization.Model): - """Properties of the sync database id. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: ARM resource id of sync database. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncDatabaseIdProperties, self).__init__(**kwargs) - self.id = None - - -class SyncFullSchemaProperties(msrest.serialization.Model): - """Properties of the database full schema. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tables: List of tables in the database full schema. - :vartype tables: list[~azure.mgmt.sql.models.SyncFullSchemaTable] - :ivar last_update_time: Last update time of the database schema. - :vartype last_update_time: ~datetime.datetime - """ - - _validation = { - 'tables': {'readonly': True}, - 'last_update_time': {'readonly': True}, - } - - _attribute_map = { - 'tables': {'key': 'tables', 'type': '[SyncFullSchemaTable]'}, - 'last_update_time': {'key': 'lastUpdateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncFullSchemaProperties, self).__init__(**kwargs) - self.tables = None - self.last_update_time = None - - -class SyncFullSchemaPropertiesListResult(msrest.serialization.Model): - """A list of sync schema properties. - - 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.SyncFullSchemaProperties] - :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': '[SyncFullSchemaProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncFullSchemaPropertiesListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SyncFullSchemaTable(msrest.serialization.Model): - """Properties of the table in the database full schema. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar columns: List of columns in the table of database full schema. - :vartype columns: list[~azure.mgmt.sql.models.SyncFullSchemaTableColumn] - :ivar error_id: Error id of the table. - :vartype error_id: str - :ivar has_error: If there is error in the table. - :vartype has_error: bool - :ivar name: Name of the table. - :vartype name: str - :ivar quoted_name: Quoted name of the table. - :vartype quoted_name: str - """ - - _validation = { - 'columns': {'readonly': True}, - 'error_id': {'readonly': True}, - 'has_error': {'readonly': True}, - 'name': {'readonly': True}, - 'quoted_name': {'readonly': True}, - } - - _attribute_map = { - 'columns': {'key': 'columns', 'type': '[SyncFullSchemaTableColumn]'}, - 'error_id': {'key': 'errorId', 'type': 'str'}, - 'has_error': {'key': 'hasError', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'quoted_name': {'key': 'quotedName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncFullSchemaTable, self).__init__(**kwargs) - self.columns = None - self.error_id = None - self.has_error = None - self.name = None - self.quoted_name = None - - -class SyncFullSchemaTableColumn(msrest.serialization.Model): - """Properties of the column in the table of database full schema. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar data_size: Data size of the column. - :vartype data_size: str - :ivar data_type: Data type of the column. - :vartype data_type: str - :ivar error_id: Error id of the column. - :vartype error_id: str - :ivar has_error: If there is error in the table. - :vartype has_error: bool - :ivar is_primary_key: If it is the primary key of the table. - :vartype is_primary_key: bool - :ivar name: Name of the column. - :vartype name: str - :ivar quoted_name: Quoted name of the column. - :vartype quoted_name: str - """ - - _validation = { - 'data_size': {'readonly': True}, - 'data_type': {'readonly': True}, - 'error_id': {'readonly': True}, - 'has_error': {'readonly': True}, - 'is_primary_key': {'readonly': True}, - 'name': {'readonly': True}, - 'quoted_name': {'readonly': True}, - } - - _attribute_map = { - 'data_size': {'key': 'dataSize', 'type': 'str'}, - 'data_type': {'key': 'dataType', 'type': 'str'}, - 'error_id': {'key': 'errorId', 'type': 'str'}, - 'has_error': {'key': 'hasError', 'type': 'bool'}, - 'is_primary_key': {'key': 'isPrimaryKey', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'quoted_name': {'key': 'quotedName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncFullSchemaTableColumn, self).__init__(**kwargs) - self.data_size = None - self.data_type = None - self.error_id = None - self.has_error = None - self.is_primary_key = None - self.name = None - self.quoted_name = None - - -class SyncGroup(ProxyResource): - """An Azure SQL Database sync group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param sku: The name and capacity of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param interval: Sync interval of the sync group. - :type interval: int - :ivar last_sync_time: Last sync time of the sync group. - :vartype last_sync_time: ~datetime.datetime - :param conflict_resolution_policy: Conflict resolution policy of the sync group. Possible - values include: "HubWin", "MemberWin". - :type conflict_resolution_policy: str or ~azure.mgmt.sql.models.SyncConflictResolutionPolicy - :param sync_database_id: ARM resource id of the sync database in the sync group. - :type sync_database_id: str - :param hub_database_user_name: User name for the sync group hub database credential. - :type hub_database_user_name: str - :param hub_database_password: Password for the sync group hub database credential. - :type hub_database_password: str - :ivar sync_state: Sync state of the sync group. Possible values include: "NotReady", "Error", - "Warning", "Progressing", "Good". - :vartype sync_state: str or ~azure.mgmt.sql.models.SyncGroupState - :param schema: Sync schema of the sync group. - :type schema: ~azure.mgmt.sql.models.SyncGroupSchema - :param enable_conflict_logging: If conflict logging is enabled. - :type enable_conflict_logging: bool - :param conflict_logging_retention_in_days: Conflict logging retention period. - :type conflict_logging_retention_in_days: int - :param use_private_link_connection: If use private link connection is enabled. - :type use_private_link_connection: bool - :ivar private_endpoint_name: Private endpoint name of the sync group if use private link - connection is enabled. - :vartype private_endpoint_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'sync_state': {'readonly': True}, - 'private_endpoint_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'interval': {'key': 'properties.interval', 'type': 'int'}, - 'last_sync_time': {'key': 'properties.lastSyncTime', 'type': 'iso-8601'}, - 'conflict_resolution_policy': {'key': 'properties.conflictResolutionPolicy', 'type': 'str'}, - 'sync_database_id': {'key': 'properties.syncDatabaseId', 'type': 'str'}, - 'hub_database_user_name': {'key': 'properties.hubDatabaseUserName', 'type': 'str'}, - 'hub_database_password': {'key': 'properties.hubDatabasePassword', 'type': 'str'}, - 'sync_state': {'key': 'properties.syncState', 'type': 'str'}, - 'schema': {'key': 'properties.schema', 'type': 'SyncGroupSchema'}, - 'enable_conflict_logging': {'key': 'properties.enableConflictLogging', 'type': 'bool'}, - 'conflict_logging_retention_in_days': {'key': 'properties.conflictLoggingRetentionInDays', 'type': 'int'}, - 'use_private_link_connection': {'key': 'properties.usePrivateLinkConnection', 'type': 'bool'}, - 'private_endpoint_name': {'key': 'properties.privateEndpointName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroup, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.interval = kwargs.get('interval', None) - self.last_sync_time = None - self.conflict_resolution_policy = kwargs.get('conflict_resolution_policy', None) - self.sync_database_id = kwargs.get('sync_database_id', None) - self.hub_database_user_name = kwargs.get('hub_database_user_name', None) - self.hub_database_password = kwargs.get('hub_database_password', None) - self.sync_state = None - self.schema = kwargs.get('schema', None) - self.enable_conflict_logging = kwargs.get('enable_conflict_logging', None) - self.conflict_logging_retention_in_days = kwargs.get('conflict_logging_retention_in_days', None) - self.use_private_link_connection = kwargs.get('use_private_link_connection', None) - self.private_endpoint_name = None - - -class SyncGroupListResult(msrest.serialization.Model): - """A list of sync groups. - - 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.SyncGroup] - :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': '[SyncGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SyncGroupLogListResult(msrest.serialization.Model): - """A list of sync group log properties. - - 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.SyncGroupLogProperties] - :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': '[SyncGroupLogProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupLogListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SyncGroupLogProperties(msrest.serialization.Model): - """Properties of an Azure SQL Database sync group log. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar timestamp: Timestamp of the sync group log. - :vartype timestamp: ~datetime.datetime - :ivar type: Type of the sync group log. Possible values include: "All", "Error", "Warning", - "Success". - :vartype type: str or ~azure.mgmt.sql.models.SyncGroupLogType - :ivar source: Source of the sync group log. - :vartype source: str - :ivar details: Details of the sync group log. - :vartype details: str - :ivar tracing_id: TracingId of the sync group log. - :vartype tracing_id: str - :ivar operation_status: OperationStatus of the sync group log. - :vartype operation_status: str - """ - - _validation = { - 'timestamp': {'readonly': True}, - 'type': {'readonly': True}, - 'source': {'readonly': True}, - 'details': {'readonly': True}, - 'tracing_id': {'readonly': True}, - 'operation_status': {'readonly': True}, - } - - _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, - 'tracing_id': {'key': 'tracingId', 'type': 'str'}, - 'operation_status': {'key': 'operationStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupLogProperties, self).__init__(**kwargs) - self.timestamp = None - self.type = None - self.source = None - self.details = None - self.tracing_id = None - self.operation_status = None - - -class SyncGroupSchema(msrest.serialization.Model): - """Properties of sync group schema. - - :param tables: List of tables in sync group schema. - :type tables: list[~azure.mgmt.sql.models.SyncGroupSchemaTable] - :param master_sync_member_name: Name of master sync member where the schema is from. - :type master_sync_member_name: str - """ - - _attribute_map = { - 'tables': {'key': 'tables', 'type': '[SyncGroupSchemaTable]'}, - 'master_sync_member_name': {'key': 'masterSyncMemberName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupSchema, self).__init__(**kwargs) - self.tables = kwargs.get('tables', None) - self.master_sync_member_name = kwargs.get('master_sync_member_name', None) - - -class SyncGroupSchemaTable(msrest.serialization.Model): - """Properties of table in sync group schema. - - :param columns: List of columns in sync group schema. - :type columns: list[~azure.mgmt.sql.models.SyncGroupSchemaTableColumn] - :param quoted_name: Quoted name of sync group schema table. - :type quoted_name: str - """ - - _attribute_map = { - 'columns': {'key': 'columns', 'type': '[SyncGroupSchemaTableColumn]'}, - 'quoted_name': {'key': 'quotedName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupSchemaTable, self).__init__(**kwargs) - self.columns = kwargs.get('columns', None) - self.quoted_name = kwargs.get('quoted_name', None) - - -class SyncGroupSchemaTableColumn(msrest.serialization.Model): - """Properties of column in sync group table. - - :param quoted_name: Quoted name of sync group table column. - :type quoted_name: str - :param data_size: Data size of the column. - :type data_size: str - :param data_type: Data type of the column. - :type data_type: str - """ - - _attribute_map = { - 'quoted_name': {'key': 'quotedName', 'type': 'str'}, - 'data_size': {'key': 'dataSize', 'type': 'str'}, - 'data_type': {'key': 'dataType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupSchemaTableColumn, self).__init__(**kwargs) - self.quoted_name = kwargs.get('quoted_name', None) - self.data_size = kwargs.get('data_size', None) - self.data_type = kwargs.get('data_type', None) - - -class SyncMember(ProxyResource): - """An Azure SQL Database sync member. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param database_type: Database type of the sync member. Possible values include: - "AzureSqlDatabase", "SqlServerDatabase". - :type database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType - :param sync_agent_id: ARM resource id of the sync agent in the sync member. - :type sync_agent_id: str - :param sql_server_database_id: SQL Server database id of the sync member. - :type sql_server_database_id: str - :param sync_member_azure_database_resource_id: ARM resource id of the sync member logical - database, for sync members in Azure. - :type sync_member_azure_database_resource_id: str - :param use_private_link_connection: Whether to use private link connection. - :type use_private_link_connection: bool - :ivar private_endpoint_name: Private endpoint name of the sync member if use private link - connection is enabled, for sync members in Azure. - :vartype private_endpoint_name: str - :param server_name: Server name of the member database in the sync member. - :type server_name: str - :param database_name: Database name of the member database in the sync member. - :type database_name: str - :param user_name: User name of the member database in the sync member. - :type user_name: str - :param password: Password of the member database in the sync member. - :type password: str - :param sync_direction: Sync direction of the sync member. Possible values include: - "Bidirectional", "OneWayMemberToHub", "OneWayHubToMember". - :type sync_direction: str or ~azure.mgmt.sql.models.SyncDirection - :ivar sync_state: Sync state of the sync member. Possible values include: "SyncInProgress", - "SyncSucceeded", "SyncFailed", "DisabledTombstoneCleanup", "DisabledBackupRestore", - "SyncSucceededWithWarnings", "SyncCancelling", "SyncCancelled", "UnProvisioned", - "Provisioning", "Provisioned", "ProvisionFailed", "DeProvisioning", "DeProvisioned", - "DeProvisionFailed", "Reprovisioning", "ReprovisionFailed", "UnReprovisioned". - :vartype sync_state: str or ~azure.mgmt.sql.models.SyncMemberState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'private_endpoint_name': {'readonly': True}, - 'sync_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_type': {'key': 'properties.databaseType', 'type': 'str'}, - 'sync_agent_id': {'key': 'properties.syncAgentId', 'type': 'str'}, - 'sql_server_database_id': {'key': 'properties.sqlServerDatabaseId', 'type': 'str'}, - 'sync_member_azure_database_resource_id': {'key': 'properties.syncMemberAzureDatabaseResourceId', 'type': 'str'}, - 'use_private_link_connection': {'key': 'properties.usePrivateLinkConnection', 'type': 'bool'}, - 'private_endpoint_name': {'key': 'properties.privateEndpointName', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'sync_direction': {'key': 'properties.syncDirection', 'type': 'str'}, - 'sync_state': {'key': 'properties.syncState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncMember, self).__init__(**kwargs) - self.database_type = kwargs.get('database_type', None) - self.sync_agent_id = kwargs.get('sync_agent_id', None) - self.sql_server_database_id = kwargs.get('sql_server_database_id', None) - self.sync_member_azure_database_resource_id = kwargs.get('sync_member_azure_database_resource_id', None) - self.use_private_link_connection = kwargs.get('use_private_link_connection', None) - self.private_endpoint_name = None - self.server_name = kwargs.get('server_name', None) - self.database_name = kwargs.get('database_name', None) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - self.sync_direction = kwargs.get('sync_direction', None) - self.sync_state = None - - -class SyncMemberListResult(msrest.serialization.Model): - """A list of Azure SQL Database sync members. - - 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.SyncMember] - :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': '[SyncMember]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncMemberListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TdeCertificate(ProxyResource): - """A TDE certificate that can be uploaded into a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param private_blob: The base64 encoded certificate private blob. - :type private_blob: str - :param cert_password: The certificate password. - :type cert_password: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_blob': {'key': 'properties.privateBlob', 'type': 'str'}, - 'cert_password': {'key': 'properties.certPassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TdeCertificate, self).__init__(**kwargs) - self.private_blob = kwargs.get('private_blob', None) - self.cert_password = kwargs.get('cert_password', None) - - -class TimeZone(ProxyResource): - """Time Zone. - - 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 time_zone_id: The time zone id. - :vartype time_zone_id: str - :ivar display_name: The time zone display name. - :vartype display_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'time_zone_id': {'readonly': True}, - 'display_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TimeZone, self).__init__(**kwargs) - self.time_zone_id = None - self.display_name = None - - -class TimeZoneListResult(msrest.serialization.Model): - """A list of time zones. - - 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.TimeZone] - :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': '[TimeZone]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TimeZoneListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class TopQueries(msrest.serialization.Model): - """TopQueries. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar number_of_queries: Requested number of top queries. - :vartype number_of_queries: int - :ivar aggregation_function: Aggregation function used to calculate query metrics. - :vartype aggregation_function: str - :ivar observation_metric: Metric used to rank queries. - :vartype observation_metric: str - :ivar interval_type: Interval type (length). Possible values include: "PT1H", "P1D". - :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: str - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: str - :param queries: List of top resource consuming queries with appropriate metric data. - :type queries: list[~azure.mgmt.sql.models.QueryStatisticsProperties] - """ - - _validation = { - 'number_of_queries': {'readonly': True}, - 'aggregation_function': {'readonly': True}, - 'observation_metric': {'readonly': True}, - 'interval_type': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'number_of_queries': {'key': 'numberOfQueries', 'type': 'int'}, - 'aggregation_function': {'key': 'aggregationFunction', 'type': 'str'}, - 'observation_metric': {'key': 'observationMetric', 'type': 'str'}, - 'interval_type': {'key': 'intervalType', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - 'queries': {'key': 'queries', 'type': '[QueryStatisticsProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(TopQueries, self).__init__(**kwargs) - self.number_of_queries = None - self.aggregation_function = None - self.observation_metric = None - self.interval_type = None - self.start_time = None - self.end_time = None - self.queries = kwargs.get('queries', None) - - -class TopQueriesListResult(msrest.serialization.Model): - """A list of top resource consuming queries on managed instance. - - 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.TopQueries] - :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': '[TopQueries]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TopQueriesListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UnlinkParameters(msrest.serialization.Model): - """Represents the parameters for Unlink Replication Link request. - - :param forced_termination: Determines whether link will be terminated in a forced or a friendly - way. - :type forced_termination: bool - """ - - _attribute_map = { - 'forced_termination': {'key': 'forcedTermination', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(UnlinkParameters, self).__init__(**kwargs) - self.forced_termination = kwargs.get('forced_termination', None) - - -class UpdateLongTermRetentionBackupParameters(msrest.serialization.Model): - """Contains the information necessary to perform long term retention backup update operation. - - :param requested_backup_storage_redundancy: The storage redundancy type of the copied backup. - Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _attribute_map = { - 'requested_backup_storage_redundancy': {'key': 'properties.requestedBackupStorageRedundancy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateLongTermRetentionBackupParameters, self).__init__(**kwargs) - self.requested_backup_storage_redundancy = kwargs.get('requested_backup_storage_redundancy', None) - - -class UpdateManagedInstanceDnsServersOperation(ProxyResource): - """A recoverable managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar status: The status of the DNS refresh operation. Possible values include: "Succeeded", - "Failed". - :vartype status: str or ~azure.mgmt.sql.models.DnsRefreshConfigurationPropertiesStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateManagedInstanceDnsServersOperation, self).__init__(**kwargs) - self.status = None - - -class UpsertManagedServerOperationParameters(msrest.serialization.Model): - """UpsertManagedServerOperationParameters. - - :param family: - :type family: str - :param tier: - :type tier: str - :param v_cores: - :type v_cores: int - :param storage_size_in_gb: - :type storage_size_in_gb: int - """ - - _attribute_map = { - 'family': {'key': 'family', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'v_cores': {'key': 'vCores', 'type': 'int'}, - 'storage_size_in_gb': {'key': 'storageSizeInGB', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpsertManagedServerOperationParameters, self).__init__(**kwargs) - self.family = kwargs.get('family', None) - self.tier = kwargs.get('tier', None) - self.v_cores = kwargs.get('v_cores', None) - self.storage_size_in_gb = kwargs.get('storage_size_in_gb', None) - - -class UpsertManagedServerOperationStep(msrest.serialization.Model): - """UpsertManagedServerOperationStep. - - :param order: - :type order: int - :param name: - :type name: str - :param status: Possible values include: "NotStarted", "InProgress", "SlowedDown", "Completed", - "Failed", "Canceled". - :type status: str or ~azure.mgmt.sql.models.UpsertManagedServerOperationStepStatus - """ - - _attribute_map = { - 'order': {'key': 'order', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpsertManagedServerOperationStep, self).__init__(**kwargs) - self.order = kwargs.get('order', None) - self.name = kwargs.get('name', None) - self.status = kwargs.get('status', None) - - -class Usage(msrest.serialization.Model): - """ARM usage. - - 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: ~azure.mgmt.sql.models.Name - :ivar type: Resource type. - :vartype type: str - :ivar unit: Usage unit. - :vartype unit: str - :ivar current_value: Usage current value. - :vartype current_value: int - :ivar limit: Usage limit. - :vartype limit: int - :ivar requested_limit: Usage requested limit. - :vartype requested_limit: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'requested_limit': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'Name'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'requested_limit': {'key': 'requestedLimit', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Usage, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.unit = None - self.current_value = None - self.limit = None - self.requested_limit = None - - -class UsageListResult(msrest.serialization.Model): - """A list of usages. - - 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.Usage] - :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': '[Usage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UserIdentity(msrest.serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The Azure Active Directory principal id. - :vartype principal_id: str - :ivar client_id: The Azure Active Directory client id. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class VirtualCluster(TrackedResource): - """An Azure SQL virtual cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar subnet_id: Subnet resource ID for the virtual cluster. - :vartype subnet_id: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :ivar child_resources: List of resources in this virtual cluster. - :vartype child_resources: list[str] - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this - virtual cluster. - :type maintenance_configuration_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'subnet_id': {'readonly': True}, - 'child_resources': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'subnet_id': {'key': 'properties.subnetId', 'type': 'str'}, - 'family': {'key': 'properties.family', 'type': 'str'}, - 'child_resources': {'key': 'properties.childResources', 'type': '[str]'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualCluster, self).__init__(**kwargs) - self.subnet_id = None - self.family = kwargs.get('family', None) - self.child_resources = None - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - - -class VirtualClusterListResult(msrest.serialization.Model): - """A list of virtual clusters. - - 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.VirtualCluster] - :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': '[VirtualCluster]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualClusterListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class VirtualClusterUpdate(msrest.serialization.Model): - """An update request for an Azure SQL Database virtual cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar subnet_id: Subnet resource ID for the virtual cluster. - :vartype subnet_id: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :ivar child_resources: List of resources in this virtual cluster. - :vartype child_resources: list[str] - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this - virtual cluster. - :type maintenance_configuration_id: str - """ - - _validation = { - 'subnet_id': {'readonly': True}, - 'child_resources': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'subnet_id': {'key': 'properties.subnetId', 'type': 'str'}, - 'family': {'key': 'properties.family', 'type': 'str'}, - 'child_resources': {'key': 'properties.childResources', 'type': '[str]'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualClusterUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.subnet_id = None - self.family = kwargs.get('family', None) - self.child_resources = None - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - - -class VirtualNetworkRule(ProxyResource): - """A virtual network rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param virtual_network_subnet_id: The ARM resource id of the virtual network subnet. - :type virtual_network_subnet_id: str - :param ignore_missing_vnet_service_endpoint: Create firewall rule before the virtual network - has vnet service endpoint enabled. - :type ignore_missing_vnet_service_endpoint: bool - :ivar state: Virtual Network Rule State. Possible values include: "Initializing", "InProgress", - "Ready", "Failed", "Deleting", "Unknown". - :vartype state: str or ~azure.mgmt.sql.models.VirtualNetworkRuleState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'virtual_network_subnet_id': {'key': 'properties.virtualNetworkSubnetId', 'type': 'str'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'properties.ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkRule, self).__init__(**kwargs) - self.virtual_network_subnet_id = kwargs.get('virtual_network_subnet_id', None) - self.ignore_missing_vnet_service_endpoint = kwargs.get('ignore_missing_vnet_service_endpoint', None) - self.state = None - - -class VirtualNetworkRuleListResult(msrest.serialization.Model): - """A list of virtual network rules. - - 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.VirtualNetworkRule] - :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': '[VirtualNetworkRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkRuleListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class VulnerabilityAssessmentRecurringScansProperties(msrest.serialization.Model): - """Properties of a Vulnerability Assessment recurring scans. - - :param is_enabled: Recurring scans state. - :type is_enabled: bool - :param email_subscription_admins: Specifies that the schedule scan notification will be is sent - to the subscription administrators. - :type email_subscription_admins: bool - :param emails: Specifies an array of e-mail addresses to which the scan notification is sent. - :type emails: list[str] - """ - - _attribute_map = { - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'email_subscription_admins': {'key': 'emailSubscriptionAdmins', 'type': 'bool'}, - 'emails': {'key': 'emails', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(VulnerabilityAssessmentRecurringScansProperties, self).__init__(**kwargs) - self.is_enabled = kwargs.get('is_enabled', None) - self.email_subscription_admins = kwargs.get('email_subscription_admins', True) - self.emails = kwargs.get('emails', None) - - -class VulnerabilityAssessmentScanError(msrest.serialization.Model): - """Properties of a vulnerability assessment scan error. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VulnerabilityAssessmentScanError, self).__init__(**kwargs) - self.code = None - self.message = None - - -class VulnerabilityAssessmentScanRecord(ProxyResource): - """A vulnerability assessment scan record. - - 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 scan_id: The scan ID. - :vartype scan_id: str - :ivar trigger_type: The scan trigger type. Possible values include: "OnDemand", "Recurring". - :vartype trigger_type: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanTriggerType - :ivar state: The scan status. Possible values include: "Passed", "Failed", "FailedToRun", - "InProgress". - :vartype state: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanState - :ivar start_time: The scan start time (UTC). - :vartype start_time: ~datetime.datetime - :ivar end_time: The scan end time (UTC). - :vartype end_time: ~datetime.datetime - :ivar errors: The scan errors. - :vartype errors: list[~azure.mgmt.sql.models.VulnerabilityAssessmentScanError] - :ivar storage_container_path: The scan results storage container path. - :vartype storage_container_path: str - :ivar number_of_failed_security_checks: The number of failed security checks. - :vartype number_of_failed_security_checks: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'scan_id': {'readonly': True}, - 'trigger_type': {'readonly': True}, - 'state': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'errors': {'readonly': True}, - 'storage_container_path': {'readonly': True}, - 'number_of_failed_security_checks': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scan_id': {'key': 'properties.scanId', 'type': 'str'}, - 'trigger_type': {'key': 'properties.triggerType', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'errors': {'key': 'properties.errors', 'type': '[VulnerabilityAssessmentScanError]'}, - 'storage_container_path': {'key': 'properties.storageContainerPath', 'type': 'str'}, - 'number_of_failed_security_checks': {'key': 'properties.numberOfFailedSecurityChecks', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(VulnerabilityAssessmentScanRecord, self).__init__(**kwargs) - self.scan_id = None - self.trigger_type = None - self.state = None - self.start_time = None - self.end_time = None - self.errors = None - self.storage_container_path = None - self.number_of_failed_security_checks = None - - -class VulnerabilityAssessmentScanRecordListResult(msrest.serialization.Model): - """A list of vulnerability assessment scan records. - - 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.VulnerabilityAssessmentScanRecord] - :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': '[VulnerabilityAssessmentScanRecord]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VulnerabilityAssessmentScanRecordListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadClassifier(ProxyResource): - """Workload classifier operations for a data warehouse. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param member_name: The workload classifier member name. - :type member_name: str - :param label: The workload classifier label. - :type label: str - :param context: The workload classifier context. - :type context: str - :param start_time: The workload classifier start time for classification. - :type start_time: str - :param end_time: The workload classifier end time for classification. - :type end_time: str - :param importance: The workload classifier importance. - :type importance: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'member_name': {'key': 'properties.memberName', 'type': 'str'}, - 'label': {'key': 'properties.label', 'type': 'str'}, - 'context': {'key': 'properties.context', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'str'}, - 'end_time': {'key': 'properties.endTime', 'type': 'str'}, - 'importance': {'key': 'properties.importance', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadClassifier, self).__init__(**kwargs) - self.member_name = kwargs.get('member_name', None) - self.label = kwargs.get('label', None) - self.context = kwargs.get('context', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.importance = kwargs.get('importance', None) - - -class WorkloadClassifierListResult(msrest.serialization.Model): - """A list of workload classifiers for a workload group. - - 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.WorkloadClassifier] - :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': '[WorkloadClassifier]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadClassifierListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadGroup(ProxyResource): - """Workload group operations for a data warehouse. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param min_resource_percent: The workload group minimum percentage resource. - :type min_resource_percent: int - :param max_resource_percent: The workload group cap percentage resource. - :type max_resource_percent: int - :param min_resource_percent_per_request: The workload group request minimum grant percentage. - :type min_resource_percent_per_request: float - :param max_resource_percent_per_request: The workload group request maximum grant percentage. - :type max_resource_percent_per_request: float - :param importance: The workload group importance level. - :type importance: str - :param query_execution_timeout: The workload group query execution timeout. - :type query_execution_timeout: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'min_resource_percent': {'key': 'properties.minResourcePercent', 'type': 'int'}, - 'max_resource_percent': {'key': 'properties.maxResourcePercent', 'type': 'int'}, - 'min_resource_percent_per_request': {'key': 'properties.minResourcePercentPerRequest', 'type': 'float'}, - 'max_resource_percent_per_request': {'key': 'properties.maxResourcePercentPerRequest', 'type': 'float'}, - 'importance': {'key': 'properties.importance', 'type': 'str'}, - 'query_execution_timeout': {'key': 'properties.queryExecutionTimeout', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadGroup, self).__init__(**kwargs) - self.min_resource_percent = kwargs.get('min_resource_percent', None) - self.max_resource_percent = kwargs.get('max_resource_percent', None) - self.min_resource_percent_per_request = kwargs.get('min_resource_percent_per_request', None) - self.max_resource_percent_per_request = kwargs.get('max_resource_percent_per_request', None) - self.importance = kwargs.get('importance', None) - self.query_execution_timeout = kwargs.get('query_execution_timeout', None) - - -class WorkloadGroupListResult(msrest.serialization.Model): - """A list of workload groups. - - 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.WorkloadGroup] - :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': '[WorkloadGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadGroupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None 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 2f5c2873f211b..ee5ec46603f7b 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 @@ -39,6 +39,8 @@ def __init__( self, **kwargs ): + """ + """ super(AdministratorListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -73,6 +75,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -108,6 +112,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) @@ -130,10 +136,10 @@ class Advisor(ProxyResource): values are 'GA', 'PublicPreview', 'LimitedPublicPreview' and 'PrivatePreview'. Possible values include: "GA", "PublicPreview", "LimitedPublicPreview", "PrivatePreview". :vartype advisor_status: str or ~azure.mgmt.sql.models.AdvisorStatus - :param auto_execute_status: Gets the auto-execute status (whether to let the system execute the + :ivar auto_execute_status: Gets the auto-execute status (whether to let the system execute the recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. Possible values include: "Enabled", "Disabled", "Default". - :type auto_execute_status: str or ~azure.mgmt.sql.models.AutoExecuteStatus + :vartype auto_execute_status: str or ~azure.mgmt.sql.models.AutoExecuteStatus :ivar auto_execute_status_inherited_from: Gets the resource from which current value of auto-execute status is inherited. Auto-execute status can be set on (and inherited from) different levels in the resource hierarchy. Possible values are 'Subscription', 'Server', @@ -186,6 +192,12 @@ def __init__( auto_execute_status: Optional[Union[str, "AutoExecuteStatus"]] = None, **kwargs ): + """ + :keyword auto_execute_status: Gets the auto-execute status (whether to let the system execute + the recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. Possible + values include: "Enabled", "Disabled", "Default". + :paramtype auto_execute_status: str or ~azure.mgmt.sql.models.AutoExecuteStatus + """ super(Advisor, self).__init__(**kwargs) self.kind = None self.location = None @@ -202,9 +214,9 @@ class AutomaticTuningOptions(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param desired_state: Automatic tuning option desired state. Possible values include: "Off", + :ivar desired_state: Automatic tuning option desired state. Possible values include: "Off", "On", "Default". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired :ivar actual_state: Automatic tuning option actual state. Possible values include: "Off", "On". :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual :ivar reason_code: Reason code if desired and actual state are different. @@ -234,6 +246,11 @@ def __init__( desired_state: Optional[Union[str, "AutomaticTuningOptionModeDesired"]] = None, **kwargs ): + """ + :keyword desired_state: Automatic tuning option desired state. Possible values include: "Off", + "On", "Default". + :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + """ super(AutomaticTuningOptions, self).__init__(**kwargs) self.desired_state = desired_state self.actual_state = None @@ -246,9 +263,9 @@ class AutomaticTuningServerOptions(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param desired_state: Automatic tuning option desired state. Possible values include: "Off", + :ivar desired_state: Automatic tuning option desired state. Possible values include: "Off", "On", "Default". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired :ivar actual_state: Automatic tuning option actual state. Possible values include: "Off", "On". :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual :ivar reason_code: Reason code if desired and actual state are different. @@ -277,6 +294,11 @@ def __init__( desired_state: Optional[Union[str, "AutomaticTuningOptionModeDesired"]] = None, **kwargs ): + """ + :keyword desired_state: Automatic tuning option desired state. Possible values include: "Off", + "On", "Default". + :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + """ super(AutomaticTuningServerOptions, self).__init__(**kwargs) self.desired_state = desired_state self.actual_state = None @@ -326,6 +348,8 @@ def __init__( self, **kwargs ): + """ + """ super(AutoPauseDelayTimeRange, self).__init__(**kwargs) self.min_value = None self.max_value = None @@ -360,6 +384,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureADOnlyAuthListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -376,13 +402,13 @@ class BackupShortTermRetentionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param retention_days: The backup retention period in days. This is how many days Point-in-Time + :ivar retention_days: The backup retention period in days. This is how many days Point-in-Time Restore will be supported. - :type retention_days: int - :param diff_backup_interval_in_hours: The differential backup interval in hours. This is how + :vartype retention_days: int + :ivar diff_backup_interval_in_hours: The differential backup interval in hours. This is how many interval hours between each differential backup will be supported. This is only applicable to live databases but not dropped databases. Possible values include: 12, 24. - :type diff_backup_interval_in_hours: str or ~azure.mgmt.sql.models.DiffBackupIntervalInHours + :vartype diff_backup_interval_in_hours: int or ~azure.mgmt.sql.models.DiffBackupIntervalInHours """ _validation = { @@ -406,6 +432,16 @@ def __init__( diff_backup_interval_in_hours: Optional[Union[int, "DiffBackupIntervalInHours"]] = None, **kwargs ): + """ + :keyword retention_days: The backup retention period in days. This is how many days + Point-in-Time Restore will be supported. + :paramtype retention_days: int + :keyword diff_backup_interval_in_hours: The differential backup interval in hours. This is how + many interval hours between each differential backup will be supported. This is only applicable + to live databases but not dropped databases. Possible values include: 12, 24. + :paramtype diff_backup_interval_in_hours: int or + ~azure.mgmt.sql.models.DiffBackupIntervalInHours + """ super(BackupShortTermRetentionPolicy, self).__init__(**kwargs) self.retention_days = retention_days self.diff_backup_interval_in_hours = diff_backup_interval_in_hours @@ -436,6 +472,8 @@ def __init__( self, **kwargs ): + """ + """ super(BackupShortTermRetentionPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -448,8 +486,8 @@ class CheckNameAvailabilityRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str + :ivar name: Required. + :vartype name: str :ivar type: Has constant value: "Microsoft.Sql/servers". :vartype type: str """ @@ -472,6 +510,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. + :paramtype name: str + """ super(CheckNameAvailabilityRequest, self).__init__(**kwargs) self.name = name @@ -511,6 +553,8 @@ def __init__( self, **kwargs ): + """ + """ super(CheckNameAvailabilityResponse, self).__init__(**kwargs) self.name = None self.available = None @@ -523,8 +567,8 @@ class CompleteDatabaseRestoreDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param last_backup_name: Required. The last backup name to apply. - :type last_backup_name: str + :ivar last_backup_name: Required. The last backup name to apply. + :vartype last_backup_name: str """ _validation = { @@ -541,6 +585,10 @@ def __init__( last_backup_name: str, **kwargs ): + """ + :keyword last_backup_name: Required. The last backup name to apply. + :paramtype last_backup_name: str + """ super(CompleteDatabaseRestoreDefinition, self).__init__(**kwargs) self.last_backup_name = last_backup_name @@ -548,20 +596,21 @@ def __init__( class CopyLongTermRetentionBackupParameters(msrest.serialization.Model): """Contains the information necessary to perform long term retention backup copy operation. - :param target_subscription_id: The subscription that owns the target server. - :type target_subscription_id: str - :param target_resource_group: The resource group that owns the target server. - :type target_resource_group: str - :param target_server_resource_id: The resource Id of the target server that owns the database. - :type target_server_resource_id: str - :param target_server_fully_qualified_domain_name: The fully qualified domain name of the target + :ivar target_subscription_id: The subscription that owns the target server. + :vartype target_subscription_id: str + :ivar target_resource_group: The resource group that owns the target server. + :vartype target_resource_group: str + :ivar target_server_resource_id: The resource Id of the target server that owns the database. + :vartype target_server_resource_id: str + :ivar target_server_fully_qualified_domain_name: The fully qualified domain name of the target server. - :type target_server_fully_qualified_domain_name: str - :param target_database_name: The name of the database owns the copied backup. - :type target_database_name: str - :param target_backup_storage_redundancy: The storage redundancy type of the copied backup. + :vartype target_server_fully_qualified_domain_name: str + :ivar target_database_name: The name of the database owns the copied backup. + :vartype target_database_name: str + :ivar target_backup_storage_redundancy: The storage redundancy type of the copied backup. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type target_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy + :vartype target_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy """ _attribute_map = { @@ -584,6 +633,24 @@ def __init__( target_backup_storage_redundancy: Optional[Union[str, "BackupStorageRedundancy"]] = None, **kwargs ): + """ + :keyword target_subscription_id: The subscription that owns the target server. + :paramtype target_subscription_id: str + :keyword target_resource_group: The resource group that owns the target server. + :paramtype target_resource_group: str + :keyword target_server_resource_id: The resource Id of the target server that owns the + database. + :paramtype target_server_resource_id: str + :keyword target_server_fully_qualified_domain_name: The fully qualified domain name of the + target server. + :paramtype target_server_fully_qualified_domain_name: str + :keyword target_database_name: The name of the database owns the copied backup. + :paramtype target_database_name: str + :keyword target_backup_storage_redundancy: The storage redundancy type of the copied backup. + Possible values include: "Geo", "Local", "Zone", "GeoZone". + :paramtype target_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + """ super(CopyLongTermRetentionBackupParameters, self).__init__(**kwargs) self.target_subscription_id = target_subscription_id self.target_resource_group = target_resource_group @@ -598,8 +665,8 @@ class CreateDatabaseRestorePointDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param restore_point_label: Required. The restore point label to apply. - :type restore_point_label: str + :ivar restore_point_label: Required. The restore point label to apply. + :vartype restore_point_label: str """ _validation = { @@ -616,6 +683,10 @@ def __init__( restore_point_label: str, **kwargs ): + """ + :keyword restore_point_label: Required. The restore point label to apply. + :paramtype restore_point_label: str + """ super(CreateDatabaseRestorePointDefinition, self).__init__(**kwargs) self.restore_point_label = restore_point_label @@ -633,10 +704,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -661,6 +732,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -679,11 +756,11 @@ class Database(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The database SKU. + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The database SKU. The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an @@ -699,14 +776,14 @@ class Database(TrackedResource): Get-AzSqlServerServiceObjective -Location `. - :type sku: ~azure.mgmt.sql.models.Sku + :vartype sku: ~azure.mgmt.sql.models.Sku :ivar kind: Kind of database. This is metadata used for the Azure portal experience. :vartype kind: str :ivar managed_by: Resource that manages the database. :vartype managed_by: str - :param identity: The Azure Active Directory identity of the database. - :type identity: ~azure.mgmt.sql.models.DatabaseIdentity - :param create_mode: Specifies the mode of database creation. + :ivar identity: The Azure Active Directory identity of the database. + :vartype identity: ~azure.mgmt.sql.models.DatabaseIdentity + :ivar create_mode: Specifies the mode of database creation. Default: regular database creation. @@ -737,19 +814,19 @@ class Database(TrackedResource): edition. Possible values include: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", "RestoreLongTermRetentionBackup", "OnlineSecondary". - :type create_mode: str or ~azure.mgmt.sql.models.CreateMode - :param collation: The collation of the database. - :type collation: str - :param max_size_bytes: The max size of the database expressed in bytes. - :type max_size_bytes: long - :param sample_name: The name of the sample schema to apply when creating this database. - Possible values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". - :type sample_name: str or ~azure.mgmt.sql.models.SampleName - :param elastic_pool_id: The resource identifier of the elastic pool containing this database. - :type elastic_pool_id: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str + :vartype create_mode: str or ~azure.mgmt.sql.models.CreateMode + :ivar collation: The collation of the database. + :vartype collation: str + :ivar max_size_bytes: The max size of the database expressed in bytes. + :vartype max_size_bytes: long + :ivar sample_name: The name of the sample schema to apply when creating this database. Possible + values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". + :vartype sample_name: str or ~azure.mgmt.sql.models.SampleName + :ivar elastic_pool_id: The resource identifier of the elastic pool containing this database. + :vartype elastic_pool_id: str + :ivar source_database_id: The resource identifier of the source database associated with create + operation of this database. + :vartype source_database_id: str :ivar status: The status of the database. Possible values include: "Online", "Restoring", "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", @@ -769,83 +846,83 @@ class Database(TrackedResource): :vartype default_secondary_location: str :ivar failover_group_id: Failover Group resource identifier that this database belongs to. :vartype failover_group_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param source_database_deletion_date: Specifies the time that the database was deleted. - :type source_database_deletion_date: ~datetime.datetime - :param recovery_services_recovery_point_id: The resource identifier of the recovery point + :vartype restore_point_in_time: ~datetime.datetime + :ivar source_database_deletion_date: Specifies the time that the database was deleted. + :vartype source_database_deletion_date: ~datetime.datetime + :ivar recovery_services_recovery_point_id: The resource identifier of the recovery point associated with create operation of this database. - :type recovery_services_recovery_point_id: str - :param long_term_retention_backup_resource_id: The resource identifier of the long term + :vartype recovery_services_recovery_point_id: str + :ivar long_term_retention_backup_resource_id: The resource identifier of the long term retention backup associated with create operation of this database. - :type long_term_retention_backup_resource_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated + :vartype long_term_retention_backup_resource_id: str + :ivar recoverable_database_id: The resource identifier of the recoverable database associated with create operation of this database. - :type recoverable_database_id: str - :param restorable_dropped_database_id: The resource identifier of the restorable dropped + :vartype recoverable_database_id: str + :ivar restorable_dropped_database_id: The resource identifier of the restorable dropped database associated with create operation of this database. - :type restorable_dropped_database_id: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: + :vartype restorable_dropped_database_id: str + :ivar catalog_collation: Collation of the metadata catalog. Possible values include: "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param zone_redundant: Whether or not this database is zone redundant, which means the replicas + :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :ivar zone_redundant: Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this database. ``LicenseIncluded`` if you + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this database. ``LicenseIncluded`` if you need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType + :vartype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType :ivar max_log_size_bytes: The max log size for this database. :vartype max_log_size_bytes: long :ivar earliest_restore_date: This records the earliest start date and time that restore is available for this database (ISO8601 format). :vartype earliest_restore_date: ~datetime.datetime - :param read_scale: The state of read-only routing. If enabled, connections that have - application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Possible values include: "Enabled", "Disabled". - :type read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :param high_availability_replica_count: The number of secondary replicas associated with the + :ivar read_scale: The state of read-only routing. If enabled, connections that have application + intent set to readonly in their connection string may be routed to a readonly secondary replica + in the same region. Possible values include: "Enabled", "Disabled". + :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale + :ivar high_availability_replica_count: The number of secondary replicas associated with the database that are used to provide high availability. - :type high_availability_replica_count: int - :param secondary_type: The secondary type of the database if it is a secondary. Valid values + :vartype high_availability_replica_count: int + :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: "Geo", "Named". - :type secondary_type: str or ~azure.mgmt.sql.models.SecondaryType + :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType :ivar current_sku: The name and tier of the SKU. :vartype current_sku: ~azure.mgmt.sql.models.Sku - :param auto_pause_delay: Time in minutes after which database is automatically paused. A value + :ivar auto_pause_delay: Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled. - :type auto_pause_delay: int + :vartype auto_pause_delay: int :ivar current_backup_storage_redundancy: The storage account type used to store backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". :vartype current_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or + :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups + for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". + :vartype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param min_capacity: Minimal capacity that database will always have allocated, if not paused. - :type min_capacity: float + :ivar min_capacity: Minimal capacity that database will always have allocated, if not paused. + :vartype min_capacity: float :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. :vartype paused_date: ~datetime.datetime :ivar resumed_date: The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. :vartype resumed_date: ~datetime.datetime - :param maintenance_configuration_id: Maintenance configuration id assigned to the database. - This configuration defines the period when the maintenance updates will occur. - :type maintenance_configuration_id: str - :param is_ledger_on: Whether or not this database is a ledger database, which means all tables + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the database. This + configuration defines the period when the maintenance updates will occur. + :vartype maintenance_configuration_id: str + :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. - :type is_ledger_on: bool + :vartype is_ledger_on: bool :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. :vartype is_infra_encryption_enabled: bool - :param federated_client_id: The Client id used for cross tenant per database CMK scenario. - :type federated_client_id: str - :param primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for + :ivar federated_client_id: The Client id used for cross tenant per database CMK scenario. + :vartype federated_client_id: str + :ivar primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for per database CMK - for internal use only. - :type primary_delegated_identity_client_id: str + :vartype primary_delegated_identity_client_id: str """ _validation = { @@ -956,6 +1033,134 @@ def __init__( primary_delegated_identity_client_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: The database SKU. + + The list of SKUs may vary by region and support offer. To determine the SKUs (including the + SKU name, tier/edition, family, and capacity) that are available to your subscription in an + Azure region, use the ``Capabilities_ListByLocation`` REST API or one of the following + commands: + + .. code-block:: azurecli + + az sql db list-editions -l -o table + ` + + .. code-block:: powershell + + Get-AzSqlServerServiceObjective -Location + `. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword identity: The Azure Active Directory identity of the database. + :paramtype identity: ~azure.mgmt.sql.models.DatabaseIdentity + :keyword create_mode: Specifies the mode of database creation. + + Default: regular database creation. + + Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified + as the resource ID of the source database. + + Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId + must be specified as the resource ID of the existing primary database. + + PointInTimeRestore: Creates a database by restoring a point in time backup of an existing + database. sourceDatabaseId must be specified as the resource ID of the existing database, and + restorePointInTime must be specified. + + Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be + specified as the recoverable database resource ID to restore. + + Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must + be specified. If sourceDatabaseId is the database's original resource ID, then + sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable + dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may + also be specified to restore from an earlier point in time. + + RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention + vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource + ID. + + Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse + edition. Possible values include: "Default", "Copy", "Secondary", "PointInTimeRestore", + "Restore", "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", + "RestoreLongTermRetentionBackup", "OnlineSecondary". + :paramtype create_mode: str or ~azure.mgmt.sql.models.CreateMode + :keyword collation: The collation of the database. + :paramtype collation: str + :keyword max_size_bytes: The max size of the database expressed in bytes. + :paramtype max_size_bytes: long + :keyword sample_name: The name of the sample schema to apply when creating this database. + Possible values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". + :paramtype sample_name: str or ~azure.mgmt.sql.models.SampleName + :keyword elastic_pool_id: The resource identifier of the elastic pool containing this database. + :paramtype elastic_pool_id: str + :keyword source_database_id: The resource identifier of the source database associated with + create operation of this database. + :paramtype source_database_id: str + :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + database that will be restored to create the new database. + :paramtype restore_point_in_time: ~datetime.datetime + :keyword source_database_deletion_date: Specifies the time that the database was deleted. + :paramtype source_database_deletion_date: ~datetime.datetime + :keyword recovery_services_recovery_point_id: The resource identifier of the recovery point + associated with create operation of this database. + :paramtype recovery_services_recovery_point_id: str + :keyword long_term_retention_backup_resource_id: The resource identifier of the long term + retention backup associated with create operation of this database. + :paramtype long_term_retention_backup_resource_id: str + :keyword recoverable_database_id: The resource identifier of the recoverable database + associated with create operation of this database. + :paramtype recoverable_database_id: str + :keyword restorable_dropped_database_id: The resource identifier of the restorable dropped + database associated with create operation of this database. + :paramtype restorable_dropped_database_id: str + :keyword catalog_collation: Collation of the metadata catalog. Possible values include: + "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". + :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :keyword zone_redundant: Whether or not this database is zone redundant, which means the + replicas of this database will be spread across multiple availability zones. + :paramtype zone_redundant: bool + :keyword license_type: The license type to apply for this database. ``LicenseIncluded`` if you + need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid + Benefit. Possible values include: "LicenseIncluded", "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType + :keyword read_scale: The state of read-only routing. If enabled, connections that have + application intent set to readonly in their connection string may be routed to a readonly + secondary replica in the same region. Possible values include: "Enabled", "Disabled". + :paramtype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale + :keyword high_availability_replica_count: The number of secondary replicas associated with the + database that are used to provide high availability. + :paramtype high_availability_replica_count: int + :keyword secondary_type: The secondary type of the database if it is a secondary. Valid values + are Geo and Named. Possible values include: "Geo", "Named". + :paramtype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType + :keyword auto_pause_delay: Time in minutes after which database is automatically paused. A + value of -1 means that automatic pause is disabled. + :paramtype auto_pause_delay: int + :keyword requested_backup_storage_redundancy: The storage account type to be used to store + backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". + :paramtype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :keyword min_capacity: Minimal capacity that database will always have allocated, if not + paused. + :paramtype min_capacity: float + :keyword maintenance_configuration_id: Maintenance configuration id assigned to the database. + This configuration defines the period when the maintenance updates will occur. + :paramtype maintenance_configuration_id: str + :keyword is_ledger_on: Whether or not this database is a ledger database, which means all + tables in the database are ledger tables. Note: the value of this property cannot be changed + after the database has been created. + :paramtype is_ledger_on: bool + :keyword federated_client_id: The Client id used for cross tenant per database CMK scenario. + :paramtype federated_client_id: str + :keyword primary_delegated_identity_client_id: The Primary Delegated Identity Client id used + for per database CMK - for internal use only. + :paramtype primary_delegated_identity_client_id: str + """ super(Database, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.kind = None @@ -1013,14 +1218,14 @@ class DatabaseAutomaticTuning(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param desired_state: Automatic tuning desired state. Possible values include: "Inherit", + :ivar desired_state: Automatic tuning desired state. Possible values include: "Inherit", "Custom", "Auto", "Unspecified". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode :ivar actual_state: Automatic tuning actual state. Possible values include: "Inherit", "Custom", "Auto", "Unspecified". :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode - :param options: Automatic tuning options definition. - :type options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] + :ivar options: Automatic tuning options definition. + :vartype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] """ _validation = { @@ -1046,6 +1251,13 @@ def __init__( options: Optional[Dict[str, "AutomaticTuningOptions"]] = None, **kwargs ): + """ + :keyword desired_state: Automatic tuning desired state. Possible values include: "Inherit", + "Custom", "Auto", "Unspecified". + :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode + :keyword options: Automatic tuning options definition. + :paramtype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] + """ super(DatabaseAutomaticTuning, self).__init__(**kwargs) self.desired_state = desired_state self.actual_state = None @@ -1065,10 +1277,10 @@ class DatabaseBlobAuditingPolicy(ProxyResource): :vartype type: str :ivar kind: Resource kind. :vartype kind: str - :param retention_days: Specifies the number of days to keep in the audit logs in the storage + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and @@ -1136,11 +1348,11 @@ class DatabaseBlobAuditingPolicy(ProxyResource): For more information, see `Database-Level Audit Actions `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. @@ -1156,20 +1368,19 @@ class DatabaseBlobAuditingPolicy(ProxyResource): For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + :vartype queue_delay_ms: int + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. @@ -1181,9 +1392,9 @@ class DatabaseBlobAuditingPolicy(ProxyResource): Contributor' RBAC role to the server identity. For more information, see `Auditing to storage using Managed Identity authentication `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str """ _validation = { @@ -1223,6 +1434,127 @@ def __init__( storage_account_subscription_id: Optional[str] = None, **kwargs ): + """ + :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :paramtype retention_days: int + :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that :code:`` in the above format can refer to an object like a table, view, or + stored procedure, or an entire database or schema. For the latter cases, the forms + DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :paramtype audit_actions_and_groups: list[str] + :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is + the storage's secondary key. + :paramtype is_storage_secondary_key_in_use: bool + :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :paramtype is_azure_monitor_target_enabled: bool + :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before + audit actions are forced to be processed. + The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + :paramtype queue_delay_ms: int + :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the auditing storage + account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see `Auditing to storage using Managed Identity authentication + `_. + :paramtype storage_account_access_key: str + :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. + :paramtype storage_account_subscription_id: str + """ super(DatabaseBlobAuditingPolicy, self).__init__(**kwargs) self.kind = None self.retention_days = retention_days @@ -1261,6 +1593,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseBlobAuditingPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1277,19 +1611,19 @@ class DatabaseColumn(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param column_type: The column data type. Possible values include: "image", "text", + :ivar column_type: The column data type. Possible values include: "image", "text", "uniqueidentifier", "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", "int", "smalldatetime", "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", "decimal", "numeric", "smallmoney", "bigint", "hierarchyid", "geometry", "geography", "varbinary", "varchar", "binary", "char", "timestamp", "nvarchar", "nchar", "xml", "sysname". - :type column_type: str or ~azure.mgmt.sql.models.ColumnDataType - :param temporal_type: The table temporal type. Possible values include: "NonTemporalTable", + :vartype column_type: str or ~azure.mgmt.sql.models.ColumnDataType + :ivar temporal_type: The table temporal type. Possible values include: "NonTemporalTable", "HistoryTable", "SystemVersionedTemporalTable". - :type temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :param memory_optimized: Whether or not the column belongs to a memory optimized table. - :type memory_optimized: bool - :param is_computed: Whether or not the column is computed. - :type is_computed: bool + :vartype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType + :ivar memory_optimized: Whether or not the column belongs to a memory optimized table. + :vartype memory_optimized: bool + :ivar is_computed: Whether or not the column is computed. + :vartype is_computed: bool """ _validation = { @@ -1317,6 +1651,21 @@ def __init__( is_computed: Optional[bool] = None, **kwargs ): + """ + :keyword column_type: The column data type. Possible values include: "image", "text", + "uniqueidentifier", "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", + "int", "smalldatetime", "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", + "decimal", "numeric", "smallmoney", "bigint", "hierarchyid", "geometry", "geography", + "varbinary", "varchar", "binary", "char", "timestamp", "nvarchar", "nchar", "xml", "sysname". + :paramtype column_type: str or ~azure.mgmt.sql.models.ColumnDataType + :keyword temporal_type: The table temporal type. Possible values include: "NonTemporalTable", + "HistoryTable", "SystemVersionedTemporalTable". + :paramtype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType + :keyword memory_optimized: Whether or not the column belongs to a memory optimized table. + :paramtype memory_optimized: bool + :keyword is_computed: Whether or not the column is computed. + :paramtype is_computed: bool + """ super(DatabaseColumn, self).__init__(**kwargs) self.column_type = column_type self.temporal_type = temporal_type @@ -1349,6 +1698,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseColumnListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1365,15 +1716,15 @@ class DatabaseExtensions(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param operation_mode: Operation Mode. Possible values include: "PolybaseImport". - :type operation_mode: str or ~azure.mgmt.sql.models.OperationMode - :param storage_key_type: Storage key type. Possible values include: "SharedAccessKey", + :ivar operation_mode: Operation Mode. Possible values include: "PolybaseImport". + :vartype operation_mode: str or ~azure.mgmt.sql.models.OperationMode + :ivar storage_key_type: Storage key type. Possible values include: "SharedAccessKey", "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Storage key. - :type storage_key: str - :param storage_uri: Storage Uri. - :type storage_uri: str + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Storage key. + :vartype storage_key: str + :ivar storage_uri: Storage Uri. + :vartype storage_uri: str """ _validation = { @@ -1401,6 +1752,17 @@ def __init__( storage_uri: Optional[str] = None, **kwargs ): + """ + :keyword operation_mode: Operation Mode. Possible values include: "PolybaseImport". + :paramtype operation_mode: str or ~azure.mgmt.sql.models.OperationMode + :keyword storage_key_type: Storage key type. Possible values include: "SharedAccessKey", + "StorageAccessKey". + :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :keyword storage_key: Storage key. + :paramtype storage_key: str + :keyword storage_uri: Storage Uri. + :paramtype storage_uri: str + """ super(DatabaseExtensions, self).__init__(**kwargs) self.operation_mode = operation_mode self.storage_key_type = storage_key_type @@ -1413,14 +1775,14 @@ class DatabaseIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param type: The identity type. Possible values include: "None", "UserAssigned". - :type type: str or ~azure.mgmt.sql.models.DatabaseIdentityType + :ivar type: The identity type. Possible values include: "None", "UserAssigned". + :vartype type: str or ~azure.mgmt.sql.models.DatabaseIdentityType :ivar tenant_id: The Azure Active Directory tenant id. :vartype tenant_id: str - :param user_assigned_identities: The resource ids of the user assigned identities to use. - :type user_assigned_identities: dict[str, ~azure.mgmt.sql.models.DatabaseUserIdentity] - :param delegated_resources: Resources delegated to the database - Internal Use Only. - :type delegated_resources: dict[str, ~azure.mgmt.sql.models.Delegation] + :ivar user_assigned_identities: The resource ids of the user assigned identities to use. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.DatabaseUserIdentity] + :ivar delegated_resources: Resources delegated to the database - Internal Use Only. + :vartype delegated_resources: dict[str, ~azure.mgmt.sql.models.Delegation] """ _validation = { @@ -1442,6 +1804,14 @@ def __init__( delegated_resources: Optional[Dict[str, "Delegation"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "None", "UserAssigned". + :paramtype type: str or ~azure.mgmt.sql.models.DatabaseIdentityType + :keyword user_assigned_identities: The resource ids of the user assigned identities to use. + :paramtype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.DatabaseUserIdentity] + :keyword delegated_resources: Resources delegated to the database - Internal Use Only. + :paramtype delegated_resources: dict[str, ~azure.mgmt.sql.models.Delegation] + """ super(DatabaseIdentity, self).__init__(**kwargs) self.type = type self.tenant_id = None @@ -1474,6 +1844,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1565,6 +1937,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseOperation, self).__init__(**kwargs) self.database_name = None self.operation = None @@ -1607,6 +1981,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseOperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1641,6 +2017,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseSchema, self).__init__(**kwargs) @@ -1669,6 +2047,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseSchemaListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1699,6 +2079,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseSecurityAlertListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1717,27 +2099,27 @@ class DatabaseSecurityAlertPolicy(ProxyResource): :vartype type: str :ivar system_data: SystemData of SecurityAlertPolicyResource. :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy + :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState + :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype disabled_alerts: list[str] + :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :vartype email_addresses: list[str] + :ivar email_account_admins: Specifies that the alert is sent to the account administrators. + :vartype email_account_admins: bool + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int + :vartype storage_account_access_key: str + :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. + :vartype retention_days: int :ivar creation_time: Specifies the UTC creation time of the policy. :vartype creation_time: ~datetime.datetime """ @@ -1777,6 +2159,30 @@ def __init__( retention_days: Optional[int] = None, **kwargs ): + """ + :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a + policy has not been applied yet on the specific database. Possible values include: "Enabled", + "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState + :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, + Brute_Force. + :paramtype disabled_alerts: list[str] + :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :paramtype email_addresses: list[str] + :keyword email_account_admins: Specifies that the alert is sent to the account administrators. + :paramtype email_account_admins: bool + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection + audit logs. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit + storage account. + :paramtype storage_account_access_key: str + :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit + logs. + :paramtype retention_days: int + """ super(DatabaseSecurityAlertPolicy, self).__init__(**kwargs) self.system_data = None self.state = state @@ -1800,11 +2206,11 @@ class DatabaseTable(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param temporal_type: The table temporal type. Possible values include: "NonTemporalTable", + :ivar temporal_type: The table temporal type. Possible values include: "NonTemporalTable", "HistoryTable", "SystemVersionedTemporalTable". - :type temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :param memory_optimized: Whether or not the table is memory optimized. - :type memory_optimized: bool + :vartype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType + :ivar memory_optimized: Whether or not the table is memory optimized. + :vartype memory_optimized: bool """ _validation = { @@ -1828,6 +2234,13 @@ def __init__( memory_optimized: Optional[bool] = None, **kwargs ): + """ + :keyword temporal_type: The table temporal type. Possible values include: "NonTemporalTable", + "HistoryTable", "SystemVersionedTemporalTable". + :paramtype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType + :keyword memory_optimized: Whether or not the table is memory optimized. + :paramtype memory_optimized: bool + """ super(DatabaseTable, self).__init__(**kwargs) self.temporal_type = temporal_type self.memory_optimized = memory_optimized @@ -1858,6 +2271,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseTableListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1868,13 +2283,13 @@ class DatabaseUpdate(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param identity: Database identity. - :type identity: ~azure.mgmt.sql.models.DatabaseIdentity - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param create_mode: Specifies the mode of database creation. + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar identity: Database identity. + :vartype identity: ~azure.mgmt.sql.models.DatabaseIdentity + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar create_mode: Specifies the mode of database creation. Default: regular database creation. @@ -1905,19 +2320,19 @@ class DatabaseUpdate(msrest.serialization.Model): edition. Possible values include: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", "RestoreLongTermRetentionBackup", "OnlineSecondary". - :type create_mode: str or ~azure.mgmt.sql.models.CreateMode - :param collation: The collation of the database. - :type collation: str - :param max_size_bytes: The max size of the database expressed in bytes. - :type max_size_bytes: long - :param sample_name: The name of the sample schema to apply when creating this database. - Possible values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". - :type sample_name: str or ~azure.mgmt.sql.models.SampleName - :param elastic_pool_id: The resource identifier of the elastic pool containing this database. - :type elastic_pool_id: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str + :vartype create_mode: str or ~azure.mgmt.sql.models.CreateMode + :ivar collation: The collation of the database. + :vartype collation: str + :ivar max_size_bytes: The max size of the database expressed in bytes. + :vartype max_size_bytes: long + :ivar sample_name: The name of the sample schema to apply when creating this database. Possible + values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". + :vartype sample_name: str or ~azure.mgmt.sql.models.SampleName + :ivar elastic_pool_id: The resource identifier of the elastic pool containing this database. + :vartype elastic_pool_id: str + :ivar source_database_id: The resource identifier of the source database associated with create + operation of this database. + :vartype source_database_id: str :ivar status: The status of the database. Possible values include: "Online", "Restoring", "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", @@ -1937,83 +2352,83 @@ class DatabaseUpdate(msrest.serialization.Model): :vartype default_secondary_location: str :ivar failover_group_id: Failover Group resource identifier that this database belongs to. :vartype failover_group_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param source_database_deletion_date: Specifies the time that the database was deleted. - :type source_database_deletion_date: ~datetime.datetime - :param recovery_services_recovery_point_id: The resource identifier of the recovery point + :vartype restore_point_in_time: ~datetime.datetime + :ivar source_database_deletion_date: Specifies the time that the database was deleted. + :vartype source_database_deletion_date: ~datetime.datetime + :ivar recovery_services_recovery_point_id: The resource identifier of the recovery point associated with create operation of this database. - :type recovery_services_recovery_point_id: str - :param long_term_retention_backup_resource_id: The resource identifier of the long term + :vartype recovery_services_recovery_point_id: str + :ivar long_term_retention_backup_resource_id: The resource identifier of the long term retention backup associated with create operation of this database. - :type long_term_retention_backup_resource_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated + :vartype long_term_retention_backup_resource_id: str + :ivar recoverable_database_id: The resource identifier of the recoverable database associated with create operation of this database. - :type recoverable_database_id: str - :param restorable_dropped_database_id: The resource identifier of the restorable dropped + :vartype recoverable_database_id: str + :ivar restorable_dropped_database_id: The resource identifier of the restorable dropped database associated with create operation of this database. - :type restorable_dropped_database_id: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: + :vartype restorable_dropped_database_id: str + :ivar catalog_collation: Collation of the metadata catalog. Possible values include: "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param zone_redundant: Whether or not this database is zone redundant, which means the replicas + :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :ivar zone_redundant: Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this database. ``LicenseIncluded`` if you + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this database. ``LicenseIncluded`` if you need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType + :vartype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType :ivar max_log_size_bytes: The max log size for this database. :vartype max_log_size_bytes: long :ivar earliest_restore_date: This records the earliest start date and time that restore is available for this database (ISO8601 format). :vartype earliest_restore_date: ~datetime.datetime - :param read_scale: The state of read-only routing. If enabled, connections that have - application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Possible values include: "Enabled", "Disabled". - :type read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :param high_availability_replica_count: The number of secondary replicas associated with the + :ivar read_scale: The state of read-only routing. If enabled, connections that have application + intent set to readonly in their connection string may be routed to a readonly secondary replica + in the same region. Possible values include: "Enabled", "Disabled". + :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale + :ivar high_availability_replica_count: The number of secondary replicas associated with the database that are used to provide high availability. - :type high_availability_replica_count: int - :param secondary_type: The secondary type of the database if it is a secondary. Valid values + :vartype high_availability_replica_count: int + :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: "Geo", "Named". - :type secondary_type: str or ~azure.mgmt.sql.models.SecondaryType + :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType :ivar current_sku: The name and tier of the SKU. :vartype current_sku: ~azure.mgmt.sql.models.Sku - :param auto_pause_delay: Time in minutes after which database is automatically paused. A value + :ivar auto_pause_delay: Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled. - :type auto_pause_delay: int + :vartype auto_pause_delay: int :ivar current_backup_storage_redundancy: The storage account type used to store backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". :vartype current_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or + :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups + for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". + :vartype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param min_capacity: Minimal capacity that database will always have allocated, if not paused. - :type min_capacity: float + :ivar min_capacity: Minimal capacity that database will always have allocated, if not paused. + :vartype min_capacity: float :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. :vartype paused_date: ~datetime.datetime :ivar resumed_date: The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. :vartype resumed_date: ~datetime.datetime - :param maintenance_configuration_id: Maintenance configuration id assigned to the database. - This configuration defines the period when the maintenance updates will occur. - :type maintenance_configuration_id: str - :param is_ledger_on: Whether or not this database is a ledger database, which means all tables + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the database. This + configuration defines the period when the maintenance updates will occur. + :vartype maintenance_configuration_id: str + :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. - :type is_ledger_on: bool + :vartype is_ledger_on: bool :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. :vartype is_infra_encryption_enabled: bool - :param federated_client_id: The Client id used for cross tenant per database CMK scenario. - :type federated_client_id: str - :param primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for + :ivar federated_client_id: The Client id used for cross tenant per database CMK scenario. + :vartype federated_client_id: str + :ivar primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for per database CMK - for internal use only. - :type primary_delegated_identity_client_id: str + :vartype primary_delegated_identity_client_id: str """ _validation = { @@ -2111,6 +2526,117 @@ def __init__( primary_delegated_identity_client_id: Optional[str] = None, **kwargs ): + """ + :keyword sku: The name and tier of the SKU. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword identity: Database identity. + :paramtype identity: ~azure.mgmt.sql.models.DatabaseIdentity + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword create_mode: Specifies the mode of database creation. + + Default: regular database creation. + + Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified + as the resource ID of the source database. + + Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId + must be specified as the resource ID of the existing primary database. + + PointInTimeRestore: Creates a database by restoring a point in time backup of an existing + database. sourceDatabaseId must be specified as the resource ID of the existing database, and + restorePointInTime must be specified. + + Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be + specified as the recoverable database resource ID to restore. + + Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must + be specified. If sourceDatabaseId is the database's original resource ID, then + sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable + dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may + also be specified to restore from an earlier point in time. + + RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention + vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource + ID. + + Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse + edition. Possible values include: "Default", "Copy", "Secondary", "PointInTimeRestore", + "Restore", "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", + "RestoreLongTermRetentionBackup", "OnlineSecondary". + :paramtype create_mode: str or ~azure.mgmt.sql.models.CreateMode + :keyword collation: The collation of the database. + :paramtype collation: str + :keyword max_size_bytes: The max size of the database expressed in bytes. + :paramtype max_size_bytes: long + :keyword sample_name: The name of the sample schema to apply when creating this database. + Possible values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull". + :paramtype sample_name: str or ~azure.mgmt.sql.models.SampleName + :keyword elastic_pool_id: The resource identifier of the elastic pool containing this database. + :paramtype elastic_pool_id: str + :keyword source_database_id: The resource identifier of the source database associated with + create operation of this database. + :paramtype source_database_id: str + :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + database that will be restored to create the new database. + :paramtype restore_point_in_time: ~datetime.datetime + :keyword source_database_deletion_date: Specifies the time that the database was deleted. + :paramtype source_database_deletion_date: ~datetime.datetime + :keyword recovery_services_recovery_point_id: The resource identifier of the recovery point + associated with create operation of this database. + :paramtype recovery_services_recovery_point_id: str + :keyword long_term_retention_backup_resource_id: The resource identifier of the long term + retention backup associated with create operation of this database. + :paramtype long_term_retention_backup_resource_id: str + :keyword recoverable_database_id: The resource identifier of the recoverable database + associated with create operation of this database. + :paramtype recoverable_database_id: str + :keyword restorable_dropped_database_id: The resource identifier of the restorable dropped + database associated with create operation of this database. + :paramtype restorable_dropped_database_id: str + :keyword catalog_collation: Collation of the metadata catalog. Possible values include: + "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". + :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :keyword zone_redundant: Whether or not this database is zone redundant, which means the + replicas of this database will be spread across multiple availability zones. + :paramtype zone_redundant: bool + :keyword license_type: The license type to apply for this database. ``LicenseIncluded`` if you + need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid + Benefit. Possible values include: "LicenseIncluded", "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType + :keyword read_scale: The state of read-only routing. If enabled, connections that have + application intent set to readonly in their connection string may be routed to a readonly + secondary replica in the same region. Possible values include: "Enabled", "Disabled". + :paramtype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale + :keyword high_availability_replica_count: The number of secondary replicas associated with the + database that are used to provide high availability. + :paramtype high_availability_replica_count: int + :keyword secondary_type: The secondary type of the database if it is a secondary. Valid values + are Geo and Named. Possible values include: "Geo", "Named". + :paramtype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType + :keyword auto_pause_delay: Time in minutes after which database is automatically paused. A + value of -1 means that automatic pause is disabled. + :paramtype auto_pause_delay: int + :keyword requested_backup_storage_redundancy: The storage account type to be used to store + backups for this database. Possible values include: "Geo", "Local", "Zone", "GeoZone". + :paramtype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :keyword min_capacity: Minimal capacity that database will always have allocated, if not + paused. + :paramtype min_capacity: float + :keyword maintenance_configuration_id: Maintenance configuration id assigned to the database. + This configuration defines the period when the maintenance updates will occur. + :paramtype maintenance_configuration_id: str + :keyword is_ledger_on: Whether or not this database is a ledger database, which means all + tables in the database are ledger tables. Note: the value of this property cannot be changed + after the database has been created. + :paramtype is_ledger_on: bool + :keyword federated_client_id: The Client id used for cross tenant per database CMK scenario. + :paramtype federated_client_id: str + :keyword primary_delegated_identity_client_id: The Primary Delegated Identity Client id used + for per database CMK - for internal use only. + :paramtype primary_delegated_identity_client_id: str + """ super(DatabaseUpdate, self).__init__(**kwargs) self.sku = sku self.identity = identity @@ -2201,6 +2727,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseUsage, self).__init__(**kwargs) self.display_name = None self.current_value = None @@ -2233,6 +2761,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseUsageListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2263,6 +2793,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseUserIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -2279,20 +2811,21 @@ class DatabaseVulnerabilityAssessment(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param storage_container_path: A blob storage container path to hold the scan results (e.g. + :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). It is required if server level vulnerability assessment policy doesn't set. - :type storage_container_path: str - :param storage_container_sas_key: A shared access signature (SAS Key) that has write access to + :vartype storage_container_path: str + :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. - :type storage_container_sas_key: str - :param storage_account_access_key: Specifies the identifier key of the storage account for + :vartype storage_container_sas_key: str + :ivar storage_account_access_key: Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. - :type storage_account_access_key: str - :param recurring_scans: The recurring scans settings. - :type recurring_scans: ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + :vartype storage_account_access_key: str + :ivar recurring_scans: The recurring scans settings. + :vartype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties """ _validation = { @@ -2320,6 +2853,23 @@ def __init__( recurring_scans: Optional["VulnerabilityAssessmentRecurringScansProperties"] = None, **kwargs ): + """ + :keyword storage_container_path: A blob storage container path to hold the scan results (e.g. + https://myStorage.blob.core.windows.net/VaScans/). It is required if server level + vulnerability assessment policy doesn't set. + :paramtype storage_container_path: str + :keyword storage_container_sas_key: A shared access signature (SAS Key) that has write access + to the blob container specified in 'storageContainerPath' parameter. If + 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. + :paramtype storage_container_sas_key: str + :keyword storage_account_access_key: Specifies the identifier key of the storage account for + vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, + storageAccountAccessKey is required. + :paramtype storage_account_access_key: str + :keyword recurring_scans: The recurring scans settings. + :paramtype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + """ super(DatabaseVulnerabilityAssessment, self).__init__(**kwargs) self.storage_container_path = storage_container_path self.storage_container_sas_key = storage_container_sas_key @@ -2352,6 +2902,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseVulnerabilityAssessmentListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2368,8 +2920,8 @@ class DatabaseVulnerabilityAssessmentRuleBaseline(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param baseline_results: The rule baseline result. - :type baseline_results: + :ivar baseline_results: The rule baseline result. + :vartype baseline_results: list[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem] """ @@ -2392,6 +2944,11 @@ def __init__( baseline_results: Optional[List["DatabaseVulnerabilityAssessmentRuleBaselineItem"]] = None, **kwargs ): + """ + :keyword baseline_results: The rule baseline result. + :paramtype baseline_results: + list[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem] + """ super(DatabaseVulnerabilityAssessmentRuleBaseline, self).__init__(**kwargs) self.baseline_results = baseline_results @@ -2401,8 +2958,8 @@ class DatabaseVulnerabilityAssessmentRuleBaselineItem(msrest.serialization.Model All required parameters must be populated in order to send to Azure. - :param result: Required. The rule baseline result. - :type result: list[str] + :ivar result: Required. The rule baseline result. + :vartype result: list[str] """ _validation = { @@ -2419,6 +2976,10 @@ def __init__( result: List[str], **kwargs ): + """ + :keyword result: Required. The rule baseline result. + :paramtype result: list[str] + """ super(DatabaseVulnerabilityAssessmentRuleBaselineItem, self).__init__(**kwargs) self.result = result @@ -2457,6 +3018,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseVulnerabilityAssessmentScansExport, self).__init__(**kwargs) self.exported_report_location = None @@ -2476,13 +3039,13 @@ class DataMaskingPolicy(ProxyResource): :vartype location: str :ivar kind: The kind of data masking policy. Metadata, used for Azure portal. :vartype kind: str - :param data_masking_state: The state of the data masking policy. Possible values include: + :ivar data_masking_state: The state of the data masking policy. Possible values include: "Disabled", "Enabled". - :type data_masking_state: str or ~azure.mgmt.sql.models.DataMaskingState - :param exempt_principals: The list of the exempt principals. Specifies the semicolon-separated + :vartype data_masking_state: str or ~azure.mgmt.sql.models.DataMaskingState + :ivar exempt_principals: The list of the exempt principals. Specifies the semicolon-separated list of database users for which the data masking policy does not apply. The specified users receive data results without masking for all of the database queries. - :type exempt_principals: str + :vartype exempt_principals: str :ivar application_principals: The list of the application principals. This is a legacy parameter and is no longer used. :vartype application_principals: str @@ -2519,6 +3082,15 @@ def __init__( exempt_principals: Optional[str] = None, **kwargs ): + """ + :keyword data_masking_state: The state of the data masking policy. Possible values include: + "Disabled", "Enabled". + :paramtype data_masking_state: str or ~azure.mgmt.sql.models.DataMaskingState + :keyword exempt_principals: The list of the exempt principals. Specifies the + semicolon-separated list of database users for which the data masking policy does not apply. + The specified users receive data results without masking for all of the database queries. + :paramtype exempt_principals: str + """ super(DataMaskingPolicy, self).__init__(**kwargs) self.location = None self.kind = None @@ -2545,38 +3117,38 @@ class DataMaskingRule(ProxyResource): :vartype kind: str :ivar id_properties_id: The rule Id. :vartype id_properties_id: str - :param alias_name: The alias name. This is a legacy parameter and is no longer used. - :type alias_name: str - :param rule_state: The rule state. Used to delete a rule. To delete an existing rule, specify + :ivar alias_name: The alias name. This is a legacy parameter and is no longer used. + :vartype alias_name: str + :ivar rule_state: The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState. Possible values include: "Disabled", "Enabled". - :type rule_state: str or ~azure.mgmt.sql.models.DataMaskingRuleState - :param schema_name: The schema name on which the data masking rule is applied. - :type schema_name: str - :param table_name: The table name on which the data masking rule is applied. - :type table_name: str - :param column_name: The column name on which the data masking rule is applied. - :type column_name: str - :param masking_function: The masking function that is used for the data masking rule. Possible + :vartype rule_state: str or ~azure.mgmt.sql.models.DataMaskingRuleState + :ivar schema_name: The schema name on which the data masking rule is applied. + :vartype schema_name: str + :ivar table_name: The table name on which the data masking rule is applied. + :vartype table_name: str + :ivar column_name: The column name on which the data masking rule is applied. + :vartype column_name: str + :ivar masking_function: The masking function that is used for the data masking rule. Possible values include: "Default", "CCN", "Email", "Number", "SSN", "Text". - :type masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction - :param number_from: The numberFrom property of the masking rule. Required if maskingFunction is + :vartype masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction + :ivar number_from: The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. - :type number_from: str - :param number_to: The numberTo property of the data masking rule. Required if maskingFunction - is set to Number, otherwise this parameter will be ignored. - :type number_to: str - :param prefix_size: If maskingFunction is set to Text, the number of characters to show - unmasked in the beginning of the string. Otherwise, this parameter will be ignored. - :type prefix_size: str - :param suffix_size: If maskingFunction is set to Text, the number of characters to show - unmasked at the end of the string. Otherwise, this parameter will be ignored. - :type suffix_size: str - :param replacement_string: If maskingFunction is set to Text, the character to use for masking + :vartype number_from: str + :ivar number_to: The numberTo property of the data masking rule. Required if maskingFunction is + set to Number, otherwise this parameter will be ignored. + :vartype number_to: str + :ivar prefix_size: If maskingFunction is set to Text, the number of characters to show unmasked + in the beginning of the string. Otherwise, this parameter will be ignored. + :vartype prefix_size: str + :ivar suffix_size: If maskingFunction is set to Text, the number of characters to show unmasked + at the end of the string. Otherwise, this parameter will be ignored. + :vartype suffix_size: str + :ivar replacement_string: If maskingFunction is set to Text, the character to use for masking the unexposed part of the string. Otherwise, this parameter will be ignored. - :type replacement_string: str + :vartype replacement_string: str """ _validation = { @@ -2624,6 +3196,40 @@ def __init__( replacement_string: Optional[str] = None, **kwargs ): + """ + :keyword alias_name: The alias name. This is a legacy parameter and is no longer used. + :paramtype alias_name: str + :keyword rule_state: The rule state. Used to delete a rule. To delete an existing rule, specify + the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. + However, if the rule doesn't already exist, the rule will be created with ruleState set to + enabled, regardless of the provided value of ruleState. Possible values include: "Disabled", + "Enabled". + :paramtype rule_state: str or ~azure.mgmt.sql.models.DataMaskingRuleState + :keyword schema_name: The schema name on which the data masking rule is applied. + :paramtype schema_name: str + :keyword table_name: The table name on which the data masking rule is applied. + :paramtype table_name: str + :keyword column_name: The column name on which the data masking rule is applied. + :paramtype column_name: str + :keyword masking_function: The masking function that is used for the data masking rule. + Possible values include: "Default", "CCN", "Email", "Number", "SSN", "Text". + :paramtype masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction + :keyword number_from: The numberFrom property of the masking rule. Required if maskingFunction + is set to Number, otherwise this parameter will be ignored. + :paramtype number_from: str + :keyword number_to: The numberTo property of the data masking rule. Required if maskingFunction + is set to Number, otherwise this parameter will be ignored. + :paramtype number_to: str + :keyword prefix_size: If maskingFunction is set to Text, the number of characters to show + unmasked in the beginning of the string. Otherwise, this parameter will be ignored. + :paramtype prefix_size: str + :keyword suffix_size: If maskingFunction is set to Text, the number of characters to show + unmasked at the end of the string. Otherwise, this parameter will be ignored. + :paramtype suffix_size: str + :keyword replacement_string: If maskingFunction is set to Text, the character to use for + masking the unexposed part of the string. Otherwise, this parameter will be ignored. + :paramtype replacement_string: str + """ super(DataMaskingRule, self).__init__(**kwargs) self.location = None self.kind = None @@ -2644,8 +3250,8 @@ def __init__( class DataMaskingRuleListResult(msrest.serialization.Model): """The response to a list data masking rules request. - :param value: The list of database data masking rules. - :type value: list[~azure.mgmt.sql.models.DataMaskingRule] + :ivar value: The list of database data masking rules. + :vartype value: list[~azure.mgmt.sql.models.DataMaskingRule] """ _attribute_map = { @@ -2658,6 +3264,10 @@ def __init__( value: Optional[List["DataMaskingRule"]] = None, **kwargs ): + """ + :keyword value: The list of database data masking rules. + :paramtype value: list[~azure.mgmt.sql.models.DataMaskingRule] + """ super(DataMaskingRuleListResult, self).__init__(**kwargs) self.value = value @@ -2695,6 +3305,8 @@ def __init__( self, **kwargs ): + """ + """ super(DataWarehouseUserActivities, self).__init__(**kwargs) self.active_queries_count = None @@ -2724,6 +3336,8 @@ def __init__( self, **kwargs ): + """ + """ super(DataWarehouseUserActivitiesListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2734,8 +3348,8 @@ class Delegation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_id: The resource id of the source resource - Internal Use Only. - :type resource_id: str + :ivar resource_id: The resource id of the source resource - Internal Use Only. + :vartype resource_id: str :ivar tenant_id: AAD tenant guid of the source resource identity - Internal Use Only. :vartype tenant_id: str """ @@ -2755,6 +3369,10 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: The resource id of the source resource - Internal Use Only. + :paramtype resource_id: str + """ super(Delegation, self).__init__(**kwargs) self.resource_id = resource_id self.tenant_id = None @@ -2805,6 +3423,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeletedServer, self).__init__(**kwargs) self.version = None self.deletion_time = None @@ -2837,6 +3457,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeletedServerListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2863,8 +3485,8 @@ class EditionCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -2892,6 +3514,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(EditionCapability, self).__init__(**kwargs) self.name = None self.supported_service_level_objectives = None @@ -2915,11 +3541,11 @@ class ElasticPool(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The elastic pool SKU. + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The elastic pool SKU. The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an @@ -2929,7 +3555,7 @@ class ElasticPool(TrackedResource): az sql elastic-pool list-editions -l -o table `. - :type sku: ~azure.mgmt.sql.models.Sku + :vartype sku: ~azure.mgmt.sql.models.Sku :ivar kind: Kind of elastic pool. This is metadata used for the Azure portal experience. :vartype kind: str :ivar state: The state of the elastic pool. Possible values include: "Creating", "Ready", @@ -2937,19 +3563,19 @@ class ElasticPool(TrackedResource): :vartype state: str or ~azure.mgmt.sql.models.ElasticPoolState :ivar creation_date: The creation date of the elastic pool (ISO8601 format). :vartype creation_date: ~datetime.datetime - :param max_size_bytes: The storage limit for the database elastic pool in bytes. - :type max_size_bytes: long - :param per_database_settings: The per database settings for the elastic pool. - :type per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :param zone_redundant: Whether or not this elastic pool is zone redundant, which means the + :ivar max_size_bytes: The storage limit for the database elastic pool in bytes. + :vartype max_size_bytes: long + :ivar per_database_settings: The per database settings for the elastic pool. + :vartype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings + :ivar zone_redundant: Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this elastic pool. Possible values include: + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this elastic pool. Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :param maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. + :vartype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. - :type maintenance_configuration_id: str + :vartype maintenance_configuration_id: str """ _validation = { @@ -2992,6 +3618,36 @@ def __init__( maintenance_configuration_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: The elastic pool SKU. + + The list of SKUs may vary by region and support offer. To determine the SKUs (including the + SKU name, tier/edition, family, and capacity) that are available to your subscription in an + Azure region, use the ``Capabilities_ListByLocation`` REST API or the following command: + + .. code-block:: azurecli + + az sql elastic-pool list-editions -l -o table + `. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword max_size_bytes: The storage limit for the database elastic pool in bytes. + :paramtype max_size_bytes: long + :keyword per_database_settings: The per database settings for the elastic pool. + :paramtype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings + :keyword zone_redundant: Whether or not this elastic pool is zone redundant, which means the + replicas of this elastic pool will be spread across multiple availability zones. + :paramtype zone_redundant: bool + :keyword license_type: The license type to apply for this elastic pool. Possible values + include: "LicenseIncluded", "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType + :keyword maintenance_configuration_id: Maintenance configuration id assigned to the elastic + pool. This configuration defines the period when the maintenance updates will will occur. + :paramtype maintenance_configuration_id: str + """ super(ElasticPool, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.kind = None @@ -3015,8 +3671,8 @@ class ElasticPoolActivity(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar end_time: The time the operation finished (ISO8601 format). :vartype end_time: ~datetime.datetime :ivar error_code: The error code if available. @@ -3119,6 +3775,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + """ super(ElasticPoolActivity, self).__init__(**kwargs) self.location = location self.end_time = None @@ -3148,8 +3808,8 @@ class ElasticPoolActivityListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of elastic pool activities. - :type value: list[~azure.mgmt.sql.models.ElasticPoolActivity] + :ivar value: Required. The list of elastic pool activities. + :vartype value: list[~azure.mgmt.sql.models.ElasticPoolActivity] """ _validation = { @@ -3166,6 +3826,10 @@ def __init__( value: List["ElasticPoolActivity"], **kwargs ): + """ + :keyword value: Required. The list of elastic pool activities. + :paramtype value: list[~azure.mgmt.sql.models.ElasticPoolActivity] + """ super(ElasticPoolActivityListResult, self).__init__(**kwargs) self.value = value @@ -3181,8 +3845,8 @@ class ElasticPoolDatabaseActivity(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar database_name: The database name. :vartype database_name: str :ivar end_time: The time the operation finished (ISO8601 format). @@ -3266,6 +3930,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + """ super(ElasticPoolDatabaseActivity, self).__init__(**kwargs) self.location = location self.database_name = None @@ -3290,8 +3958,8 @@ class ElasticPoolDatabaseActivityListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of elastic pool database activities. - :type value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] + :ivar value: Required. The list of elastic pool database activities. + :vartype value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] """ _validation = { @@ -3308,6 +3976,10 @@ def __init__( value: List["ElasticPoolDatabaseActivity"], **kwargs ): + """ + :keyword value: Required. The list of elastic pool database activities. + :paramtype value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] + """ super(ElasticPoolDatabaseActivityListResult, self).__init__(**kwargs) self.value = value @@ -3328,8 +4000,8 @@ class ElasticPoolEditionCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -3353,6 +4025,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ElasticPoolEditionCapability, self).__init__(**kwargs) self.name = None self.supported_elastic_pool_performance_levels = None @@ -3386,6 +4062,8 @@ def __init__( self, **kwargs ): + """ + """ super(ElasticPoolListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3476,6 +4154,8 @@ def __init__( self, **kwargs ): + """ + """ super(ElasticPoolOperation, self).__init__(**kwargs) self.elastic_pool_name = None self.operation = None @@ -3518,6 +4198,8 @@ def __init__( self, **kwargs ): + """ + """ super(ElasticPoolOperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3540,8 +4222,8 @@ class ElasticPoolPerDatabaseMaxPerformanceLevelCapability(msrest.serialization.M :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -3565,6 +4247,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ElasticPoolPerDatabaseMaxPerformanceLevelCapability, self).__init__(**kwargs) self.limit = None self.unit = None @@ -3586,8 +4272,8 @@ class ElasticPoolPerDatabaseMinPerformanceLevelCapability(msrest.serialization.M :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -3609,6 +4295,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ElasticPoolPerDatabaseMinPerformanceLevelCapability, self).__init__(**kwargs) self.limit = None self.unit = None @@ -3619,10 +4309,10 @@ def __init__( class ElasticPoolPerDatabaseSettings(msrest.serialization.Model): """Per database settings of an elastic pool. - :param min_capacity: The minimum capacity all databases are guaranteed. - :type min_capacity: float - :param max_capacity: The maximum capacity any one database can consume. - :type max_capacity: float + :ivar min_capacity: The minimum capacity all databases are guaranteed. + :vartype min_capacity: float + :ivar max_capacity: The maximum capacity any one database can consume. + :vartype max_capacity: float """ _attribute_map = { @@ -3637,6 +4327,12 @@ def __init__( max_capacity: Optional[float] = None, **kwargs ): + """ + :keyword min_capacity: The minimum capacity all databases are guaranteed. + :paramtype min_capacity: float + :keyword max_capacity: The maximum capacity any one database can consume. + :paramtype max_capacity: float + """ super(ElasticPoolPerDatabaseSettings, self).__init__(**kwargs) self.min_capacity = min_capacity self.max_capacity = max_capacity @@ -3673,8 +4369,8 @@ class ElasticPoolPerformanceLevelCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -3712,6 +4408,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ElasticPoolPerformanceLevelCapability, self).__init__(**kwargs) self.performance_level = None self.sku = None @@ -3730,23 +4430,23 @@ def __init__( class ElasticPoolUpdate(msrest.serialization.Model): """An elastic pool update. - :param sku: An ARM Resource SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param max_size_bytes: The storage limit for the database elastic pool in bytes. - :type max_size_bytes: long - :param per_database_settings: The per database settings for the elastic pool. - :type per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :param zone_redundant: Whether or not this elastic pool is zone redundant, which means the + :ivar sku: An ARM Resource SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar max_size_bytes: The storage limit for the database elastic pool in bytes. + :vartype max_size_bytes: long + :ivar per_database_settings: The per database settings for the elastic pool. + :vartype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings + :ivar zone_redundant: Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. - :type zone_redundant: bool - :param license_type: The license type to apply for this elastic pool. Possible values include: + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this elastic pool. Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :param maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. + :vartype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. - :type maintenance_configuration_id: str + :vartype maintenance_configuration_id: str """ _attribute_map = { @@ -3771,6 +4471,25 @@ def __init__( maintenance_configuration_id: Optional[str] = None, **kwargs ): + """ + :keyword sku: An ARM Resource SKU. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword max_size_bytes: The storage limit for the database elastic pool in bytes. + :paramtype max_size_bytes: long + :keyword per_database_settings: The per database settings for the elastic pool. + :paramtype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings + :keyword zone_redundant: Whether or not this elastic pool is zone redundant, which means the + replicas of this elastic pool will be spread across multiple availability zones. + :paramtype zone_redundant: bool + :keyword license_type: The license type to apply for this elastic pool. Possible values + include: "LicenseIncluded", "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType + :keyword maintenance_configuration_id: Maintenance configuration id assigned to the elastic + pool. This configuration defines the period when the maintenance updates will will occur. + :paramtype maintenance_configuration_id: str + """ super(ElasticPoolUpdate, self).__init__(**kwargs) self.sku = sku self.tags = tags @@ -3799,17 +4518,17 @@ class EncryptionProtector(ProxyResource): :vartype location: str :ivar subregion: Subregion of the encryption protector. :vartype subregion: str - :param server_key_name: The name of the server key. - :type server_key_name: str - :param server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. + :ivar server_key_name: The name of the server key. + :vartype server_key_name: str + :ivar server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType :ivar uri: The URI of the server key. :vartype uri: str :ivar thumbprint: Thumbprint of the server key. :vartype thumbprint: str - :param auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :type auto_rotation_enabled: bool + :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :vartype auto_rotation_enabled: bool """ _validation = { @@ -3845,6 +4564,15 @@ def __init__( auto_rotation_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword server_key_name: The name of the server key. + :paramtype server_key_name: str + :keyword server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. + Possible values include: "ServiceManaged", "AzureKeyVault". + :paramtype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :keyword auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :paramtype auto_rotation_enabled: bool + """ super(EncryptionProtector, self).__init__(**kwargs) self.kind = None self.location = None @@ -3881,6 +4609,8 @@ def __init__( self, **kwargs ): + """ + """ super(EncryptionProtectorListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3891,22 +4621,21 @@ class ExportDatabaseDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param storage_key_type: Required. Storage key type. Possible values include: - "SharedAccessKey", "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Required. Storage key. - :type storage_key: str - :param storage_uri: Required. Storage Uri. - :type storage_uri: str - :param administrator_login: Required. Administrator login name. - :type administrator_login: str - :param administrator_login_password: Required. Administrator login password. - :type administrator_login_password: str - :param authentication_type: Authentication type. - :type authentication_type: str - :param network_isolation: Optional resource information to enable network isolation for - request. - :type network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + :ivar storage_key_type: Required. Storage key type. Possible values include: "SharedAccessKey", + "StorageAccessKey". + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Required. Storage key. + :vartype storage_key: str + :ivar storage_uri: Required. Storage Uri. + :vartype storage_uri: str + :ivar administrator_login: Required. Administrator login name. + :vartype administrator_login: str + :ivar administrator_login_password: Required. Administrator login password. + :vartype administrator_login_password: str + :ivar authentication_type: Authentication type. + :vartype authentication_type: str + :ivar network_isolation: Optional resource information to enable network isolation for request. + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings """ _validation = { @@ -3939,6 +4668,24 @@ def __init__( network_isolation: Optional["NetworkIsolationSettings"] = None, **kwargs ): + """ + :keyword storage_key_type: Required. Storage key type. Possible values include: + "SharedAccessKey", "StorageAccessKey". + :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :keyword storage_key: Required. Storage key. + :paramtype storage_key: str + :keyword storage_uri: Required. Storage Uri. + :paramtype storage_uri: str + :keyword administrator_login: Required. Administrator login name. + :paramtype administrator_login: str + :keyword administrator_login_password: Required. Administrator login password. + :paramtype administrator_login_password: str + :keyword authentication_type: Authentication type. + :paramtype authentication_type: str + :keyword network_isolation: Optional resource information to enable network isolation for + request. + :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + """ super(ExportDatabaseDefinition, self).__init__(**kwargs) self.storage_key_type = storage_key_type self.storage_key = storage_key @@ -3960,12 +4707,12 @@ class ExtendedDatabaseBlobAuditingPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param predicate_expression: Specifies condition of where clause when creating an audit. - :type predicate_expression: str - :param retention_days: Specifies the number of days to keep in the audit logs in the storage + :ivar predicate_expression: Specifies condition of where clause when creating an audit. + :vartype predicate_expression: str + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and @@ -4033,11 +4780,11 @@ class ExtendedDatabaseBlobAuditingPolicy(ProxyResource): For more information, see `Database-Level Audit Actions `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. @@ -4053,20 +4800,19 @@ class ExtendedDatabaseBlobAuditingPolicy(ProxyResource): For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + :vartype queue_delay_ms: int + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. @@ -4078,9 +4824,9 @@ class ExtendedDatabaseBlobAuditingPolicy(ProxyResource): Contributor' RBAC role to the server identity. For more information, see `Auditing to storage using Managed Identity authentication `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str """ _validation = { @@ -4120,6 +4866,129 @@ def __init__( storage_account_subscription_id: Optional[str] = None, **kwargs ): + """ + :keyword predicate_expression: Specifies condition of where clause when creating an audit. + :paramtype predicate_expression: str + :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :paramtype retention_days: int + :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that :code:`` in the above format can refer to an object like a table, view, or + stored procedure, or an entire database or schema. For the latter cases, the forms + DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :paramtype audit_actions_and_groups: list[str] + :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is + the storage's secondary key. + :paramtype is_storage_secondary_key_in_use: bool + :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :paramtype is_azure_monitor_target_enabled: bool + :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before + audit actions are forced to be processed. + The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + :paramtype queue_delay_ms: int + :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the auditing storage + account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see `Auditing to storage using Managed Identity authentication + `_. + :paramtype storage_account_access_key: str + :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. + :paramtype storage_account_subscription_id: str + """ super(ExtendedDatabaseBlobAuditingPolicy, self).__init__(**kwargs) self.predicate_expression = predicate_expression self.retention_days = retention_days @@ -4158,6 +5027,8 @@ def __init__( self, **kwargs ): + """ + """ super(ExtendedDatabaseBlobAuditingPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4174,8 +5045,8 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, - devops logs will be sent to Azure Monitor. + :ivar is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, devops + logs will be sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true @@ -4189,13 +5060,13 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. - :type is_devops_audit_enabled: bool - :param predicate_expression: Specifies condition of where clause when creating an audit. - :type predicate_expression: str - :param retention_days: Specifies the number of days to keep in the audit logs in the storage + :vartype is_devops_audit_enabled: bool + :ivar predicate_expression: Specifies condition of where clause when creating an audit. + :vartype predicate_expression: str + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and @@ -4263,11 +5134,11 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): For more information, see `Database-Level Audit Actions `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. @@ -4283,20 +5154,19 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + :vartype queue_delay_ms: int + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. @@ -4308,9 +5178,9 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): Contributor' RBAC role to the server identity. For more information, see `Auditing to storage using Managed Identity authentication `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str """ _validation = { @@ -4352,6 +5222,145 @@ def __init__( storage_account_subscription_id: Optional[str] = None, **kwargs ): + """ + :keyword is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, + devops logs will be sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled', + 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should also be created. + + Diagnostic Settings URI format: + PUT + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :paramtype is_devops_audit_enabled: bool + :keyword predicate_expression: Specifies condition of where clause when creating an audit. + :paramtype predicate_expression: str + :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :paramtype retention_days: int + :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that :code:`` in the above format can refer to an object like a table, view, or + stored procedure, or an entire database or schema. For the latter cases, the forms + DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :paramtype audit_actions_and_groups: list[str] + :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is + the storage's secondary key. + :paramtype is_storage_secondary_key_in_use: bool + :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :paramtype is_azure_monitor_target_enabled: bool + :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before + audit actions are forced to be processed. + The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + :paramtype queue_delay_ms: int + :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the auditing storage + account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see `Auditing to storage using Managed Identity authentication + `_. + :paramtype storage_account_access_key: str + :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. + :paramtype storage_account_subscription_id: str + """ super(ExtendedServerBlobAuditingPolicy, self).__init__(**kwargs) self.is_devops_audit_enabled = is_devops_audit_enabled self.predicate_expression = predicate_expression @@ -4391,6 +5400,8 @@ def __init__( self, **kwargs ): + """ + """ super(ExtendedServerBlobAuditingPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4409,21 +5420,21 @@ class FailoverGroup(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param read_write_endpoint: Read-write endpoint of the failover group instance. - :type read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :param read_only_endpoint: Read-only endpoint of the failover group instance. - :type read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar read_write_endpoint: Read-write endpoint of the failover group instance. + :vartype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint + :ivar read_only_endpoint: Read-only endpoint of the failover group instance. + :vartype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint :ivar replication_role: Local replication role of the failover group instance. Possible values include: "Primary", "Secondary". :vartype replication_role: str or ~azure.mgmt.sql.models.FailoverGroupReplicationRole :ivar replication_state: Replication state of the failover group instance. :vartype replication_state: str - :param partner_servers: List of partner server information for the failover group. - :type partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] - :param databases: List of databases in the failover group. - :type databases: list[str] + :ivar partner_servers: List of partner server information for the failover group. + :vartype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] + :ivar databases: List of databases in the failover group. + :vartype databases: list[str] """ _validation = { @@ -4459,6 +5470,18 @@ def __init__( databases: Optional[List[str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword read_write_endpoint: Read-write endpoint of the failover group instance. + :paramtype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint + :keyword read_only_endpoint: Read-only endpoint of the failover group instance. + :paramtype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint + :keyword partner_servers: List of partner server information for the failover group. + :paramtype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] + :keyword databases: List of databases in the failover group. + :paramtype databases: list[str] + """ super(FailoverGroup, self).__init__(**kwargs) self.location = None self.tags = tags @@ -4495,6 +5518,8 @@ def __init__( self, **kwargs ): + """ + """ super(FailoverGroupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4503,9 +5528,9 @@ def __init__( class FailoverGroupReadOnlyEndpoint(msrest.serialization.Model): """Read-only endpoint of the failover group instance. - :param failover_policy: Failover policy of the read-only endpoint for the failover group. + :ivar failover_policy: Failover policy of the read-only endpoint for the failover group. Possible values include: "Disabled", "Enabled". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy + :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy """ _attribute_map = { @@ -4518,6 +5543,11 @@ def __init__( failover_policy: Optional[Union[str, "ReadOnlyEndpointFailoverPolicy"]] = None, **kwargs ): + """ + :keyword failover_policy: Failover policy of the read-only endpoint for the failover group. + Possible values include: "Disabled", "Enabled". + :paramtype failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy + """ super(FailoverGroupReadOnlyEndpoint, self).__init__(**kwargs) self.failover_policy = failover_policy @@ -4527,14 +5557,14 @@ class FailoverGroupReadWriteEndpoint(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_policy: Required. Failover policy of the read-write endpoint for the failover + :ivar failover_policy: Required. Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: "Manual", "Automatic". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :param failover_with_data_loss_grace_period_minutes: Grace period before failover with data - loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then + :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy + :ivar failover_with_data_loss_grace_period_minutes: Grace period before failover with data loss + is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. - :type failover_with_data_loss_grace_period_minutes: int + :vartype failover_with_data_loss_grace_period_minutes: int """ _validation = { @@ -4553,6 +5583,16 @@ def __init__( failover_with_data_loss_grace_period_minutes: Optional[int] = None, **kwargs ): + """ + :keyword failover_policy: Required. Failover policy of the read-write endpoint for the failover + group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + Possible values include: "Manual", "Automatic". + :paramtype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy + :keyword failover_with_data_loss_grace_period_minutes: Grace period before failover with data + loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then + failoverWithDataLossGracePeriodMinutes is required. + :paramtype failover_with_data_loss_grace_period_minutes: int + """ super(FailoverGroupReadWriteEndpoint, self).__init__(**kwargs) self.failover_policy = failover_policy self.failover_with_data_loss_grace_period_minutes = failover_with_data_loss_grace_period_minutes @@ -4561,14 +5601,14 @@ def __init__( class FailoverGroupUpdate(msrest.serialization.Model): """A failover group update request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param read_write_endpoint: Read-write endpoint of the failover group instance. - :type read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :param read_only_endpoint: Read-only endpoint of the failover group instance. - :type read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint - :param databases: List of databases in the failover group. - :type databases: list[str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar read_write_endpoint: Read-write endpoint of the failover group instance. + :vartype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint + :ivar read_only_endpoint: Read-only endpoint of the failover group instance. + :vartype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint + :ivar databases: List of databases in the failover group. + :vartype databases: list[str] """ _attribute_map = { @@ -4587,6 +5627,16 @@ def __init__( databases: Optional[List[str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword read_write_endpoint: Read-write endpoint of the failover group instance. + :paramtype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint + :keyword read_only_endpoint: Read-only endpoint of the failover group instance. + :paramtype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint + :keyword databases: List of databases in the failover group. + :paramtype databases: list[str] + """ super(FailoverGroupUpdate, self).__init__(**kwargs) self.tags = tags self.read_write_endpoint = read_write_endpoint @@ -4601,8 +5651,8 @@ class ResourceWithWritableName(msrest.serialization.Model): :ivar id: Resource ID. :vartype id: str - :param name: Resource name. - :type name: str + :ivar name: Resource name. + :vartype name: str :ivar type: Resource type. :vartype type: str """ @@ -4624,6 +5674,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Resource name. + :paramtype name: str + """ super(ResourceWithWritableName, self).__init__(**kwargs) self.id = None self.name = name @@ -4637,8 +5691,8 @@ class ProxyResourceWithWritableName(ResourceWithWritableName): :ivar id: Resource ID. :vartype id: str - :param name: Resource name. - :type name: str + :ivar name: Resource name. + :vartype name: str :ivar type: Resource type. :vartype type: str """ @@ -4660,6 +5714,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Resource name. + :paramtype name: str + """ super(ProxyResourceWithWritableName, self).__init__(name=name, **kwargs) @@ -4670,17 +5728,17 @@ class FirewallRule(ProxyResourceWithWritableName): :ivar id: Resource ID. :vartype id: str - :param name: Resource name. - :type name: str + :ivar name: Resource name. + :vartype name: str :ivar type: Resource type. :vartype type: str - :param start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. Use + :ivar start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. Use value '0.0.0.0' for all Azure-internal IP addresses. - :type start_ip_address: str - :param end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be + :vartype start_ip_address: str + :ivar end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. Use value '0.0.0.0' for all Azure-internal IP addresses. - :type end_ip_address: str + :vartype end_ip_address: str """ _validation = { @@ -4704,6 +5762,17 @@ def __init__( end_ip_address: Optional[str] = None, **kwargs ): + """ + :keyword name: Resource name. + :paramtype name: str + :keyword start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. Use + value '0.0.0.0' for all Azure-internal IP addresses. + :paramtype start_ip_address: str + :keyword end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be + greater than or equal to startIpAddress. Use value '0.0.0.0' for all Azure-internal IP + addresses. + :paramtype end_ip_address: str + """ super(FirewallRule, self).__init__(name=name, **kwargs) self.start_ip_address = start_ip_address self.end_ip_address = end_ip_address @@ -4712,8 +5781,8 @@ def __init__( class FirewallRuleList(msrest.serialization.Model): """A list of server firewall rules. - :param values: - :type values: list[~azure.mgmt.sql.models.FirewallRule] + :ivar values: + :vartype values: list[~azure.mgmt.sql.models.FirewallRule] """ _attribute_map = { @@ -4726,6 +5795,10 @@ def __init__( values: Optional[List["FirewallRule"]] = None, **kwargs ): + """ + :keyword values: + :paramtype values: list[~azure.mgmt.sql.models.FirewallRule] + """ super(FirewallRuleList, self).__init__(**kwargs) self.values = values @@ -4755,6 +5828,8 @@ def __init__( self, **kwargs ): + """ + """ super(FirewallRuleListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4777,9 +5852,9 @@ class GeoBackupPolicy(ProxyResource): :vartype kind: str :ivar location: Backup policy location. :vartype location: str - :param state: Required. The state of the geo backup policy. Possible values include: - "Disabled", "Enabled". - :type state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState + :ivar state: Required. The state of the geo backup policy. Possible values include: "Disabled", + "Enabled". + :vartype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState :ivar storage_type: The storage type of the geo backup policy. :vartype storage_type: str """ @@ -4810,6 +5885,11 @@ def __init__( state: Union[str, "GeoBackupPolicyState"], **kwargs ): + """ + :keyword state: Required. The state of the geo backup policy. Possible values include: + "Disabled", "Enabled". + :paramtype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState + """ super(GeoBackupPolicy, self).__init__(**kwargs) self.kind = None self.location = None @@ -4820,8 +5900,8 @@ def __init__( class GeoBackupPolicyListResult(msrest.serialization.Model): """The response to a list geo backup policies request. - :param value: The list of geo backup policies. - :type value: list[~azure.mgmt.sql.models.GeoBackupPolicy] + :ivar value: The list of geo backup policies. + :vartype value: list[~azure.mgmt.sql.models.GeoBackupPolicy] """ _attribute_map = { @@ -4834,6 +5914,10 @@ def __init__( value: Optional[List["GeoBackupPolicy"]] = None, **kwargs ): + """ + :keyword value: The list of geo backup policies. + :paramtype value: list[~azure.mgmt.sql.models.GeoBackupPolicy] + """ super(GeoBackupPolicyListResult, self).__init__(**kwargs) self.value = value @@ -4843,22 +5927,21 @@ class ImportExistingDatabaseDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param storage_key_type: Required. Storage key type. Possible values include: - "SharedAccessKey", "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Required. Storage key. - :type storage_key: str - :param storage_uri: Required. Storage Uri. - :type storage_uri: str - :param administrator_login: Required. Administrator login name. - :type administrator_login: str - :param administrator_login_password: Required. Administrator login password. - :type administrator_login_password: str - :param authentication_type: Authentication type. - :type authentication_type: str - :param network_isolation: Optional resource information to enable network isolation for - request. - :type network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + :ivar storage_key_type: Required. Storage key type. Possible values include: "SharedAccessKey", + "StorageAccessKey". + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Required. Storage key. + :vartype storage_key: str + :ivar storage_uri: Required. Storage Uri. + :vartype storage_uri: str + :ivar administrator_login: Required. Administrator login name. + :vartype administrator_login: str + :ivar administrator_login_password: Required. Administrator login password. + :vartype administrator_login_password: str + :ivar authentication_type: Authentication type. + :vartype authentication_type: str + :ivar network_isolation: Optional resource information to enable network isolation for request. + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings """ _validation = { @@ -4891,6 +5974,24 @@ def __init__( network_isolation: Optional["NetworkIsolationSettings"] = None, **kwargs ): + """ + :keyword storage_key_type: Required. Storage key type. Possible values include: + "SharedAccessKey", "StorageAccessKey". + :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :keyword storage_key: Required. Storage key. + :paramtype storage_key: str + :keyword storage_uri: Required. Storage Uri. + :paramtype storage_uri: str + :keyword administrator_login: Required. Administrator login name. + :paramtype administrator_login: str + :keyword administrator_login_password: Required. Administrator login password. + :paramtype administrator_login_password: str + :keyword authentication_type: Authentication type. + :paramtype authentication_type: str + :keyword network_isolation: Optional resource information to enable network isolation for + request. + :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + """ super(ImportExistingDatabaseDefinition, self).__init__(**kwargs) self.storage_key_type = storage_key_type self.storage_key = storage_key @@ -4926,6 +6027,8 @@ def __init__( self, **kwargs ): + """ + """ super(ImportExportExtensionsOperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4988,6 +6091,8 @@ def __init__( self, **kwargs ): + """ + """ super(ImportExportExtensionsOperationResult, self).__init__(**kwargs) self.request_id = None self.request_type = None @@ -5069,6 +6174,8 @@ def __init__( self, **kwargs ): + """ + """ super(ImportExportOperationResult, self).__init__(**kwargs) self.request_id = None self.request_type = None @@ -5087,30 +6194,29 @@ class ImportNewDatabaseDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param database_name: Name of the import database. - :type database_name: str - :param edition: Edition of the import database. - :type edition: str - :param service_objective_name: Service level objective name of the import database. - :type service_objective_name: str - :param max_size_bytes: Max size in bytes for the import database. - :type max_size_bytes: str - :param storage_key_type: Required. Storage key type. Possible values include: - "SharedAccessKey", "StorageAccessKey". - :type storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :param storage_key: Required. Storage key. - :type storage_key: str - :param storage_uri: Required. Storage Uri. - :type storage_uri: str - :param administrator_login: Required. Administrator login name. - :type administrator_login: str - :param administrator_login_password: Required. Administrator login password. - :type administrator_login_password: str - :param authentication_type: Authentication type. - :type authentication_type: str - :param network_isolation: Optional resource information to enable network isolation for - request. - :type network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + :ivar database_name: Name of the import database. + :vartype database_name: str + :ivar edition: Edition of the import database. + :vartype edition: str + :ivar service_objective_name: Service level objective name of the import database. + :vartype service_objective_name: str + :ivar max_size_bytes: Max size in bytes for the import database. + :vartype max_size_bytes: str + :ivar storage_key_type: Required. Storage key type. Possible values include: "SharedAccessKey", + "StorageAccessKey". + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Required. Storage key. + :vartype storage_key: str + :ivar storage_uri: Required. Storage Uri. + :vartype storage_uri: str + :ivar administrator_login: Required. Administrator login name. + :vartype administrator_login: str + :ivar administrator_login_password: Required. Administrator login password. + :vartype administrator_login_password: str + :ivar authentication_type: Authentication type. + :vartype authentication_type: str + :ivar network_isolation: Optional resource information to enable network isolation for request. + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings """ _validation = { @@ -5151,6 +6257,32 @@ def __init__( network_isolation: Optional["NetworkIsolationSettings"] = None, **kwargs ): + """ + :keyword database_name: Name of the import database. + :paramtype database_name: str + :keyword edition: Edition of the import database. + :paramtype edition: str + :keyword service_objective_name: Service level objective name of the import database. + :paramtype service_objective_name: str + :keyword max_size_bytes: Max size in bytes for the import database. + :paramtype max_size_bytes: str + :keyword storage_key_type: Required. Storage key type. Possible values include: + "SharedAccessKey", "StorageAccessKey". + :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :keyword storage_key: Required. Storage key. + :paramtype storage_key: str + :keyword storage_uri: Required. Storage Uri. + :paramtype storage_uri: str + :keyword administrator_login: Required. Administrator login name. + :paramtype administrator_login: str + :keyword administrator_login_password: Required. Administrator login password. + :paramtype administrator_login_password: str + :keyword authentication_type: Authentication type. + :paramtype authentication_type: str + :keyword network_isolation: Optional resource information to enable network isolation for + request. + :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + """ super(ImportNewDatabaseDefinition, self).__init__(**kwargs) self.database_name = database_name self.edition = edition @@ -5176,19 +6308,19 @@ class InstanceFailoverGroup(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param read_write_endpoint: Read-write endpoint of the failover group instance. - :type read_write_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint - :param read_only_endpoint: Read-only endpoint of the failover group instance. - :type read_only_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint + :ivar read_write_endpoint: Read-write endpoint of the failover group instance. + :vartype read_write_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint + :ivar read_only_endpoint: Read-only endpoint of the failover group instance. + :vartype read_only_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint :ivar replication_role: Local replication role of the failover group instance. Possible values include: "Primary", "Secondary". :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole :ivar replication_state: Replication state of the failover group instance. :vartype replication_state: str - :param partner_regions: Partner region information for the failover group. - :type partner_regions: list[~azure.mgmt.sql.models.PartnerRegionInfo] - :param managed_instance_pairs: List of managed instance pairs in the failover group. - :type managed_instance_pairs: list[~azure.mgmt.sql.models.ManagedInstancePairInfo] + :ivar partner_regions: Partner region information for the failover group. + :vartype partner_regions: list[~azure.mgmt.sql.models.PartnerRegionInfo] + :ivar managed_instance_pairs: List of managed instance pairs in the failover group. + :vartype managed_instance_pairs: list[~azure.mgmt.sql.models.ManagedInstancePairInfo] """ _validation = { @@ -5220,6 +6352,16 @@ def __init__( managed_instance_pairs: Optional[List["ManagedInstancePairInfo"]] = None, **kwargs ): + """ + :keyword read_write_endpoint: Read-write endpoint of the failover group instance. + :paramtype read_write_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint + :keyword read_only_endpoint: Read-only endpoint of the failover group instance. + :paramtype read_only_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint + :keyword partner_regions: Partner region information for the failover group. + :paramtype partner_regions: list[~azure.mgmt.sql.models.PartnerRegionInfo] + :keyword managed_instance_pairs: List of managed instance pairs in the failover group. + :paramtype managed_instance_pairs: list[~azure.mgmt.sql.models.ManagedInstancePairInfo] + """ super(InstanceFailoverGroup, self).__init__(**kwargs) self.read_write_endpoint = read_write_endpoint self.read_only_endpoint = read_only_endpoint @@ -5254,6 +6396,8 @@ def __init__( self, **kwargs ): + """ + """ super(InstanceFailoverGroupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -5262,9 +6406,9 @@ def __init__( class InstanceFailoverGroupReadOnlyEndpoint(msrest.serialization.Model): """Read-only endpoint of the failover group instance. - :param failover_policy: Failover policy of the read-only endpoint for the failover group. + :ivar failover_policy: Failover policy of the read-only endpoint for the failover group. Possible values include: "Disabled", "Enabled". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy + :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy """ _attribute_map = { @@ -5277,6 +6421,11 @@ def __init__( failover_policy: Optional[Union[str, "ReadOnlyEndpointFailoverPolicy"]] = None, **kwargs ): + """ + :keyword failover_policy: Failover policy of the read-only endpoint for the failover group. + Possible values include: "Disabled", "Enabled". + :paramtype failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy + """ super(InstanceFailoverGroupReadOnlyEndpoint, self).__init__(**kwargs) self.failover_policy = failover_policy @@ -5286,14 +6435,14 @@ class InstanceFailoverGroupReadWriteEndpoint(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_policy: Required. Failover policy of the read-write endpoint for the failover + :ivar failover_policy: Required. Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: "Manual", "Automatic". - :type failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :param failover_with_data_loss_grace_period_minutes: Grace period before failover with data - loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then + :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy + :ivar failover_with_data_loss_grace_period_minutes: Grace period before failover with data loss + is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. - :type failover_with_data_loss_grace_period_minutes: int + :vartype failover_with_data_loss_grace_period_minutes: int """ _validation = { @@ -5312,6 +6461,16 @@ def __init__( failover_with_data_loss_grace_period_minutes: Optional[int] = None, **kwargs ): + """ + :keyword failover_policy: Required. Failover policy of the read-write endpoint for the failover + group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + Possible values include: "Manual", "Automatic". + :paramtype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy + :keyword failover_with_data_loss_grace_period_minutes: Grace period before failover with data + loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then + failoverWithDataLossGracePeriodMinutes is required. + :paramtype failover_with_data_loss_grace_period_minutes: int + """ super(InstanceFailoverGroupReadWriteEndpoint, self).__init__(**kwargs) self.failover_policy = failover_policy self.failover_with_data_loss_grace_period_minutes = failover_with_data_loss_grace_period_minutes @@ -5330,20 +6489,20 @@ class InstancePool(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param subnet_id: Resource ID of the subnet to place this instance pool in. - :type subnet_id: str - :param v_cores: Count of vCores belonging to this instance pool. - :type v_cores: int - :param license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar subnet_id: Resource ID of the subnet to place this instance pool in. + :vartype subnet_id: str + :ivar v_cores: Count of vCores belonging to this instance pool. + :vartype v_cores: int + :ivar license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL license is included) and 'BasePrice' (without SQL license price). Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType + :vartype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType """ _validation = { @@ -5376,6 +6535,22 @@ def __init__( license_type: Optional[Union[str, "InstancePoolLicenseType"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: The name and tier of the SKU. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword subnet_id: Resource ID of the subnet to place this instance pool in. + :paramtype subnet_id: str + :keyword v_cores: Count of vCores belonging to this instance pool. + :paramtype v_cores: int + :keyword license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL + license is included) and 'BasePrice' (without SQL license price). Possible values include: + "LicenseIncluded", "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType + """ super(InstancePool, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.subnet_id = subnet_id @@ -5395,8 +6570,8 @@ class InstancePoolEditionCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -5418,6 +6593,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(InstancePoolEditionCapability, self).__init__(**kwargs) self.name = None self.supported_families = None @@ -5439,8 +6618,8 @@ class InstancePoolFamilyCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -5464,6 +6643,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(InstancePoolFamilyCapability, self).__init__(**kwargs) self.name = None self.supported_license_types = None @@ -5497,6 +6680,8 @@ def __init__( self, **kwargs ): + """ + """ super(InstancePoolListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -5505,8 +6690,8 @@ def __init__( class InstancePoolUpdate(msrest.serialization.Model): """An update to an Instance pool. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -5519,6 +6704,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(InstancePoolUpdate, self).__init__(**kwargs) self.tags = tags @@ -5537,8 +6726,8 @@ class InstancePoolVcoresCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -5562,6 +6751,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(InstancePoolVcoresCapability, self).__init__(**kwargs) self.name = None self.value = None @@ -5570,6 +6763,116 @@ def __init__( self.reason = reason +class IPv6FirewallRule(ProxyResourceWithWritableName): + """An IPv6 server firewall rule. + + 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 start_i_pv6_address: The start IP address of the firewall rule. Must be IPv6 format. + :vartype start_i_pv6_address: str + :ivar end_i_pv6_address: The end IP address of the firewall rule. Must be IPv6 format. Must be + greater than or equal to startIpAddress. + :vartype end_i_pv6_address: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'start_i_pv6_address': {'key': 'properties.startIPv6Address', 'type': 'str'}, + 'end_i_pv6_address': {'key': 'properties.endIPv6Address', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + start_i_pv6_address: Optional[str] = None, + end_i_pv6_address: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Resource name. + :paramtype name: str + :keyword start_i_pv6_address: The start IP address of the firewall rule. Must be IPv6 format. + :paramtype start_i_pv6_address: str + :keyword end_i_pv6_address: The end IP address of the firewall rule. Must be IPv6 format. Must + be greater than or equal to startIpAddress. + :paramtype end_i_pv6_address: str + """ + super(IPv6FirewallRule, self).__init__(name=name, **kwargs) + self.start_i_pv6_address = start_i_pv6_address + self.end_i_pv6_address = end_i_pv6_address + + +class IPv6FirewallRuleList(msrest.serialization.Model): + """A list of IPv6 server firewall rules. + + :ivar values: + :vartype values: list[~azure.mgmt.sql.models.IPv6FirewallRule] + """ + + _attribute_map = { + 'values': {'key': 'values', 'type': '[IPv6FirewallRule]'}, + } + + def __init__( + self, + *, + values: Optional[List["IPv6FirewallRule"]] = None, + **kwargs + ): + """ + :keyword values: + :paramtype values: list[~azure.mgmt.sql.models.IPv6FirewallRule] + """ + super(IPv6FirewallRuleList, self).__init__(**kwargs) + self.values = values + + +class IPv6FirewallRuleListResult(msrest.serialization.Model): + """The response to a list IPv6 firewall rules request. + + 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.IPv6FirewallRule] + :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': '[IPv6FirewallRule]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(IPv6FirewallRuleListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class Job(ProxyResource): """A job. @@ -5581,12 +6884,12 @@ class Job(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param description: User-defined description of the job. - :type description: str + :ivar description: User-defined description of the job. + :vartype description: str :ivar version: The job version number. :vartype version: int - :param schedule: Schedule properties of the job. - :type schedule: ~azure.mgmt.sql.models.JobSchedule + :ivar schedule: Schedule properties of the job. + :vartype schedule: ~azure.mgmt.sql.models.JobSchedule """ _validation = { @@ -5612,6 +6915,12 @@ def __init__( schedule: Optional["JobSchedule"] = None, **kwargs ): + """ + :keyword description: User-defined description of the job. + :paramtype description: str + :keyword schedule: Schedule properties of the job. + :paramtype schedule: ~azure.mgmt.sql.models.JobSchedule + """ super(Job, self).__init__(**kwargs) self.description = description self.version = None @@ -5631,14 +6940,14 @@ class JobAgent(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param database_id: Resource ID of the database to store job metadata in. - :type database_id: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar database_id: Resource ID of the database to store job metadata in. + :vartype database_id: str :ivar state: The state of the job agent. Possible values include: "Creating", "Ready", "Updating", "Deleting", "Disabled". :vartype state: str or ~azure.mgmt.sql.models.JobAgentState @@ -5672,6 +6981,16 @@ def __init__( database_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: The name and tier of the SKU. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword database_id: Resource ID of the database to store job metadata in. + :paramtype database_id: str + """ super(JobAgent, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.database_id = database_id @@ -5703,6 +7022,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobAgentListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -5711,8 +7032,8 @@ def __init__( class JobAgentUpdate(msrest.serialization.Model): """An update to an Azure SQL job agent. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -5725,6 +7046,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(JobAgentUpdate, self).__init__(**kwargs) self.tags = tags @@ -5740,10 +7065,10 @@ class JobCredential(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param username: The credential user name. - :type username: str - :param password: The credential password. - :type password: str + :ivar username: The credential user name. + :vartype username: str + :ivar password: The credential password. + :vartype password: str """ _validation = { @@ -5767,6 +7092,12 @@ def __init__( password: Optional[str] = None, **kwargs ): + """ + :keyword username: The credential user name. + :paramtype username: str + :keyword password: The credential password. + :paramtype password: str + """ super(JobCredential, self).__init__(**kwargs) self.username = username self.password = password @@ -5797,6 +7128,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobCredentialListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -5834,8 +7167,8 @@ class JobExecution(ProxyResource): :vartype start_time: ~datetime.datetime :ivar end_time: The time that the job execution completed. :vartype end_time: ~datetime.datetime - :param current_attempts: Number of times the job execution has been attempted. - :type current_attempts: int + :ivar current_attempts: Number of times the job execution has been attempted. + :vartype current_attempts: int :ivar current_attempt_start_time: Start time of the current attempt. :vartype current_attempt_start_time: ~datetime.datetime :ivar last_message: The last status or error message. @@ -5887,6 +7220,10 @@ def __init__( current_attempts: Optional[int] = None, **kwargs ): + """ + :keyword current_attempts: Number of times the job execution has been attempted. + :paramtype current_attempts: int + """ super(JobExecution, self).__init__(**kwargs) self.job_version = None self.step_name = None @@ -5928,6 +7265,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobExecutionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -5963,6 +7302,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobExecutionTarget, self).__init__(**kwargs) self.type = None self.server_name = None @@ -5994,6 +7335,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6002,18 +7345,18 @@ def __init__( class JobSchedule(msrest.serialization.Model): """Scheduling properties of a job. - :param start_time: Schedule start time. - :type start_time: ~datetime.datetime - :param end_time: Schedule end time. - :type end_time: ~datetime.datetime - :param type: Schedule interval type. Possible values include: "Once", "Recurring". Default + :ivar start_time: Schedule start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: Schedule end time. + :vartype end_time: ~datetime.datetime + :ivar type: Schedule interval type. Possible values include: "Once", "Recurring". Default value: "Once". - :type type: str or ~azure.mgmt.sql.models.JobScheduleType - :param enabled: Whether or not the schedule is enabled. - :type enabled: bool - :param interval: Value of the schedule's recurring interval, if the ScheduleType is recurring. + :vartype type: str or ~azure.mgmt.sql.models.JobScheduleType + :ivar enabled: Whether or not the schedule is enabled. + :vartype enabled: bool + :ivar interval: Value of the schedule's recurring interval, if the ScheduleType is recurring. ISO8601 duration format. - :type interval: str + :vartype interval: str """ _attribute_map = { @@ -6034,6 +7377,20 @@ def __init__( interval: Optional[str] = None, **kwargs ): + """ + :keyword start_time: Schedule start time. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Schedule end time. + :paramtype end_time: ~datetime.datetime + :keyword type: Schedule interval type. Possible values include: "Once", "Recurring". Default + value: "Once". + :paramtype type: str or ~azure.mgmt.sql.models.JobScheduleType + :keyword enabled: Whether or not the schedule is enabled. + :paramtype enabled: bool + :keyword interval: Value of the schedule's recurring interval, if the ScheduleType is + recurring. ISO8601 duration format. + :paramtype interval: str + """ super(JobSchedule, self).__init__(**kwargs) self.start_time = start_time self.end_time = end_time @@ -6053,21 +7410,21 @@ class JobStep(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param step_id: The job step's index within the job. If not specified when creating the job + :ivar step_id: The job step's index within the job. If not specified when creating the job step, it will be created as the last step. If not specified when updating the job step, the step id is not modified. - :type step_id: int - :param target_group: The resource ID of the target group that the job step will be executed on. - :type target_group: str - :param credential: The resource ID of the job credential that will be used to connect to the + :vartype step_id: int + :ivar target_group: The resource ID of the target group that the job step will be executed on. + :vartype target_group: str + :ivar credential: The resource ID of the job credential that will be used to connect to the targets. - :type credential: str - :param action: The action payload of the job step. - :type action: ~azure.mgmt.sql.models.JobStepAction - :param output: Output destination properties of the job step. - :type output: ~azure.mgmt.sql.models.JobStepOutput - :param execution_options: Execution options for the job step. - :type execution_options: ~azure.mgmt.sql.models.JobStepExecutionOptions + :vartype credential: str + :ivar action: The action payload of the job step. + :vartype action: ~azure.mgmt.sql.models.JobStepAction + :ivar output: Output destination properties of the job step. + :vartype output: ~azure.mgmt.sql.models.JobStepOutput + :ivar execution_options: Execution options for the job step. + :vartype execution_options: ~azure.mgmt.sql.models.JobStepExecutionOptions """ _validation = { @@ -6099,6 +7456,24 @@ def __init__( execution_options: Optional["JobStepExecutionOptions"] = None, **kwargs ): + """ + :keyword step_id: The job step's index within the job. If not specified when creating the job + step, it will be created as the last step. If not specified when updating the job step, the + step id is not modified. + :paramtype step_id: int + :keyword target_group: The resource ID of the target group that the job step will be executed + on. + :paramtype target_group: str + :keyword credential: The resource ID of the job credential that will be used to connect to the + targets. + :paramtype credential: str + :keyword action: The action payload of the job step. + :paramtype action: ~azure.mgmt.sql.models.JobStepAction + :keyword output: Output destination properties of the job step. + :paramtype output: ~azure.mgmt.sql.models.JobStepOutput + :keyword execution_options: Execution options for the job step. + :paramtype execution_options: ~azure.mgmt.sql.models.JobStepExecutionOptions + """ super(JobStep, self).__init__(**kwargs) self.step_id = step_id self.target_group = target_group @@ -6113,14 +7488,14 @@ class JobStepAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Type of action being executed by the job step. Possible values include: "TSql". + :ivar type: Type of action being executed by the job step. Possible values include: "TSql". Default value: "TSql". - :type type: str or ~azure.mgmt.sql.models.JobStepActionType - :param source: The source of the action to execute. Possible values include: "Inline". Default + :vartype type: str or ~azure.mgmt.sql.models.JobStepActionType + :ivar source: The source of the action to execute. Possible values include: "Inline". Default value: "Inline". - :type source: str or ~azure.mgmt.sql.models.JobStepActionSource - :param value: Required. The action value, for example the text of the T-SQL script to execute. - :type value: str + :vartype source: str or ~azure.mgmt.sql.models.JobStepActionSource + :ivar value: Required. The action value, for example the text of the T-SQL script to execute. + :vartype value: str """ _validation = { @@ -6141,6 +7516,17 @@ def __init__( source: Optional[Union[str, "JobStepActionSource"]] = "Inline", **kwargs ): + """ + :keyword type: Type of action being executed by the job step. Possible values include: "TSql". + Default value: "TSql". + :paramtype type: str or ~azure.mgmt.sql.models.JobStepActionType + :keyword source: The source of the action to execute. Possible values include: "Inline". + Default value: "Inline". + :paramtype source: str or ~azure.mgmt.sql.models.JobStepActionSource + :keyword value: Required. The action value, for example the text of the T-SQL script to + execute. + :paramtype value: str + """ super(JobStepAction, self).__init__(**kwargs) self.type = type self.source = source @@ -6150,18 +7536,18 @@ def __init__( class JobStepExecutionOptions(msrest.serialization.Model): """The execution options of a job step. - :param timeout_seconds: Execution timeout for the job step. - :type timeout_seconds: int - :param retry_attempts: Maximum number of times the job step will be reattempted if the first + :ivar timeout_seconds: Execution timeout for the job step. + :vartype timeout_seconds: int + :ivar retry_attempts: Maximum number of times the job step will be reattempted if the first attempt fails. - :type retry_attempts: int - :param initial_retry_interval_seconds: Initial delay between retries for job step execution. - :type initial_retry_interval_seconds: int - :param maximum_retry_interval_seconds: The maximum amount of time to wait between retries for + :vartype retry_attempts: int + :ivar initial_retry_interval_seconds: Initial delay between retries for job step execution. + :vartype initial_retry_interval_seconds: int + :ivar maximum_retry_interval_seconds: The maximum amount of time to wait between retries for job step execution. - :type maximum_retry_interval_seconds: int - :param retry_interval_backoff_multiplier: The backoff multiplier for the time between retries. - :type retry_interval_backoff_multiplier: float + :vartype maximum_retry_interval_seconds: int + :ivar retry_interval_backoff_multiplier: The backoff multiplier for the time between retries. + :vartype retry_interval_backoff_multiplier: float """ _attribute_map = { @@ -6182,6 +7568,21 @@ def __init__( retry_interval_backoff_multiplier: Optional[float] = 2, **kwargs ): + """ + :keyword timeout_seconds: Execution timeout for the job step. + :paramtype timeout_seconds: int + :keyword retry_attempts: Maximum number of times the job step will be reattempted if the first + attempt fails. + :paramtype retry_attempts: int + :keyword initial_retry_interval_seconds: Initial delay between retries for job step execution. + :paramtype initial_retry_interval_seconds: int + :keyword maximum_retry_interval_seconds: The maximum amount of time to wait between retries for + job step execution. + :paramtype maximum_retry_interval_seconds: int + :keyword retry_interval_backoff_multiplier: The backoff multiplier for the time between + retries. + :paramtype retry_interval_backoff_multiplier: float + """ super(JobStepExecutionOptions, self).__init__(**kwargs) self.timeout_seconds = timeout_seconds self.retry_attempts = retry_attempts @@ -6215,6 +7616,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobStepListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6225,24 +7628,24 @@ class JobStepOutput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: The output destination type. Possible values include: "SqlDatabase". Default - value: "SqlDatabase". - :type type: str or ~azure.mgmt.sql.models.JobStepOutputType - :param subscription_id: The output destination subscription id. - :type subscription_id: str - :param resource_group_name: The output destination resource group. - :type resource_group_name: str - :param server_name: Required. The output destination server name. - :type server_name: str - :param database_name: Required. The output destination database. - :type database_name: str - :param schema_name: The output destination schema. - :type schema_name: str - :param table_name: Required. The output destination table. - :type table_name: str - :param credential: Required. The resource ID of the credential to use to connect to the output + :ivar type: The output destination type. Possible values include: "SqlDatabase". Default value: + "SqlDatabase". + :vartype type: str or ~azure.mgmt.sql.models.JobStepOutputType + :ivar subscription_id: The output destination subscription id. + :vartype subscription_id: str + :ivar resource_group_name: The output destination resource group. + :vartype resource_group_name: str + :ivar server_name: Required. The output destination server name. + :vartype server_name: str + :ivar database_name: Required. The output destination database. + :vartype database_name: str + :ivar schema_name: The output destination schema. + :vartype schema_name: str + :ivar table_name: Required. The output destination table. + :vartype table_name: str + :ivar credential: Required. The resource ID of the credential to use to connect to the output destination. - :type credential: str + :vartype credential: str """ _validation = { @@ -6276,6 +7679,26 @@ def __init__( schema_name: Optional[str] = "dbo", **kwargs ): + """ + :keyword type: The output destination type. Possible values include: "SqlDatabase". Default + value: "SqlDatabase". + :paramtype type: str or ~azure.mgmt.sql.models.JobStepOutputType + :keyword subscription_id: The output destination subscription id. + :paramtype subscription_id: str + :keyword resource_group_name: The output destination resource group. + :paramtype resource_group_name: str + :keyword server_name: Required. The output destination server name. + :paramtype server_name: str + :keyword database_name: Required. The output destination database. + :paramtype database_name: str + :keyword schema_name: The output destination schema. + :paramtype schema_name: str + :keyword table_name: Required. The output destination table. + :paramtype table_name: str + :keyword credential: Required. The resource ID of the credential to use to connect to the + output destination. + :paramtype credential: str + """ super(JobStepOutput, self).__init__(**kwargs) self.type = type self.subscription_id = subscription_id @@ -6292,23 +7715,23 @@ class JobTarget(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param membership_type: Whether the target is included or excluded from the group. Possible + :ivar membership_type: Whether the target is included or excluded from the group. Possible values include: "Include", "Exclude". Default value: "Include". - :type membership_type: str or ~azure.mgmt.sql.models.JobTargetGroupMembershipType - :param type: Required. The target type. Possible values include: "TargetGroup", "SqlDatabase", + :vartype membership_type: str or ~azure.mgmt.sql.models.JobTargetGroupMembershipType + :ivar type: Required. The target type. Possible values include: "TargetGroup", "SqlDatabase", "SqlElasticPool", "SqlShardMap", "SqlServer". - :type type: str or ~azure.mgmt.sql.models.JobTargetType - :param server_name: The target server name. - :type server_name: str - :param database_name: The target database name. - :type database_name: str - :param elastic_pool_name: The target elastic pool name. - :type elastic_pool_name: str - :param shard_map_name: The target shard map. - :type shard_map_name: str - :param refresh_credential: The resource ID of the credential that is used during job execution + :vartype type: str or ~azure.mgmt.sql.models.JobTargetType + :ivar server_name: The target server name. + :vartype server_name: str + :ivar database_name: The target database name. + :vartype database_name: str + :ivar elastic_pool_name: The target elastic pool name. + :vartype elastic_pool_name: str + :ivar shard_map_name: The target shard map. + :vartype shard_map_name: str + :ivar refresh_credential: The resource ID of the credential that is used during job execution to connect to the target and determine the list of databases inside the target. - :type refresh_credential: str + :vartype refresh_credential: str """ _validation = { @@ -6337,6 +7760,25 @@ def __init__( refresh_credential: Optional[str] = None, **kwargs ): + """ + :keyword membership_type: Whether the target is included or excluded from the group. Possible + values include: "Include", "Exclude". Default value: "Include". + :paramtype membership_type: str or ~azure.mgmt.sql.models.JobTargetGroupMembershipType + :keyword type: Required. The target type. Possible values include: "TargetGroup", + "SqlDatabase", "SqlElasticPool", "SqlShardMap", "SqlServer". + :paramtype type: str or ~azure.mgmt.sql.models.JobTargetType + :keyword server_name: The target server name. + :paramtype server_name: str + :keyword database_name: The target database name. + :paramtype database_name: str + :keyword elastic_pool_name: The target elastic pool name. + :paramtype elastic_pool_name: str + :keyword shard_map_name: The target shard map. + :paramtype shard_map_name: str + :keyword refresh_credential: The resource ID of the credential that is used during job + execution to connect to the target and determine the list of databases inside the target. + :paramtype refresh_credential: str + """ super(JobTarget, self).__init__(**kwargs) self.membership_type = membership_type self.type = type @@ -6358,8 +7800,8 @@ class JobTargetGroup(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param members: Members of the target group. - :type members: list[~azure.mgmt.sql.models.JobTarget] + :ivar members: Members of the target group. + :vartype members: list[~azure.mgmt.sql.models.JobTarget] """ _validation = { @@ -6381,6 +7823,10 @@ def __init__( members: Optional[List["JobTarget"]] = None, **kwargs ): + """ + :keyword members: Members of the target group. + :paramtype members: list[~azure.mgmt.sql.models.JobTarget] + """ super(JobTargetGroup, self).__init__(**kwargs) self.members = members @@ -6410,6 +7856,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobTargetGroupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6444,6 +7892,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobVersion, self).__init__(**kwargs) @@ -6472,6 +7922,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobVersionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6488,9 +7940,9 @@ class LedgerDigestUploads(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param digest_storage_endpoint: The digest storage endpoint, which must be either an Azure blob + :ivar digest_storage_endpoint: The digest storage endpoint, which must be either an Azure blob storage endpoint or an URI for Azure Confidential Ledger. - :type digest_storage_endpoint: str + :vartype digest_storage_endpoint: str :ivar state: Specifies the state of ledger digest upload. Possible values include: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.sql.models.LedgerDigestUploadsState @@ -6517,6 +7969,11 @@ def __init__( digest_storage_endpoint: Optional[str] = None, **kwargs ): + """ + :keyword digest_storage_endpoint: The digest storage endpoint, which must be either an Azure + blob storage endpoint or an URI for Azure Confidential Ledger. + :paramtype digest_storage_endpoint: str + """ super(LedgerDigestUploads, self).__init__(**kwargs) self.digest_storage_endpoint = digest_storage_endpoint self.state = None @@ -6547,6 +8004,8 @@ def __init__( self, **kwargs ): + """ + """ super(LedgerDigestUploadsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6562,8 +8021,8 @@ class LicenseTypeCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -6583,6 +8042,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(LicenseTypeCapability, self).__init__(**kwargs) self.name = None self.status = None @@ -6604,8 +8067,8 @@ class LocationCapabilities(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -6629,6 +8092,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(LocationCapabilities, self).__init__(**kwargs) self.name = None self.supported_server_versions = None @@ -6648,9 +8115,9 @@ class LogicalDatabaseTransparentDataEncryption(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param state: Specifies the state of the transparent data encryption. Possible values include: + :ivar state: Specifies the state of the transparent data encryption. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + :vartype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState """ _validation = { @@ -6672,6 +8139,11 @@ def __init__( state: Optional[Union[str, "TransparentDataEncryptionState"]] = None, **kwargs ): + """ + :keyword state: Specifies the state of the transparent data encryption. Possible values + include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + """ super(LogicalDatabaseTransparentDataEncryption, self).__init__(**kwargs) self.state = state @@ -6701,6 +8173,8 @@ def __init__( self, **kwargs ): + """ + """ super(LogicalDatabaseTransparentDataEncryptionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6731,6 +8205,8 @@ def __init__( self, **kwargs ): + """ + """ super(LogicalServerSecurityAlertPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6762,6 +8238,8 @@ def __init__( self, **kwargs ): + """ + """ super(LogSizeCapability, self).__init__(**kwargs) self.limit = None self.unit = None @@ -6793,9 +8271,9 @@ class LongTermRetentionBackup(ProxyResource): :ivar backup_storage_redundancy: The storage redundancy type of the backup. Possible values include: "Geo", "Local", "Zone", "GeoZone". :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage redundancy type of the backup. Possible + :ivar requested_backup_storage_redundancy: The storage redundancy type of the backup. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or + :vartype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy """ @@ -6832,6 +8310,12 @@ def __init__( requested_backup_storage_redundancy: Optional[Union[str, "BackupStorageRedundancy"]] = None, **kwargs ): + """ + :keyword requested_backup_storage_redundancy: The storage redundancy type of the backup. + Possible values include: "Geo", "Local", "Zone", "GeoZone". + :paramtype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + """ super(LongTermRetentionBackup, self).__init__(**kwargs) self.server_name = None self.server_create_time = None @@ -6868,6 +8352,8 @@ def __init__( self, **kwargs ): + """ + """ super(LongTermRetentionBackupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6932,6 +8418,8 @@ def __init__( self, **kwargs ): + """ + """ super(LongTermRetentionBackupOperationResult, self).__init__(**kwargs) self.request_id = None self.operation_type = None @@ -6953,14 +8441,14 @@ class LongTermRetentionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :type weekly_retention: str - :param monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. - :type monthly_retention: str - :param yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :type yearly_retention: str - :param week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :type week_of_year: int + :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :vartype weekly_retention: str + :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. + :vartype monthly_retention: str + :ivar yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :vartype yearly_retention: str + :ivar week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :vartype week_of_year: int """ _validation = { @@ -6988,6 +8476,17 @@ def __init__( week_of_year: Optional[int] = None, **kwargs ): + """ + :keyword weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :paramtype weekly_retention: str + :keyword monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 + format. + :paramtype monthly_retention: str + :keyword yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :paramtype yearly_retention: str + :keyword week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :paramtype week_of_year: int + """ super(LongTermRetentionPolicy, self).__init__(**kwargs) self.weekly_retention = weekly_retention self.monthly_retention = monthly_retention @@ -7020,6 +8519,8 @@ def __init__( self, **kwargs ): + """ + """ super(LongTermRetentionPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -7038,8 +8539,8 @@ class MaintenanceConfigurationCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -7061,6 +8562,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(MaintenanceConfigurationCapability, self).__init__(**kwargs) self.name = None self.zone_redundant = None @@ -7079,22 +8584,22 @@ class MaintenanceWindowOptions(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param is_enabled: Whether maintenance windows are enabled for the database. - :type is_enabled: bool - :param maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\ *60}, + :ivar is_enabled: Whether maintenance windows are enabled for the database. + :vartype is_enabled: bool + :ivar maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\ *60}, {Wednesday, 0, 24*\ 60}. - :type maintenance_window_cycles: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] - :param min_duration_in_minutes: Minimum duration of maintenance window. - :type min_duration_in_minutes: int - :param default_duration_in_minutes: Default duration for maintenance window. - :type default_duration_in_minutes: int - :param min_cycles: Minimum number of maintenance windows cycles to be set on the database. - :type min_cycles: int - :param time_granularity_in_minutes: Time granularity in minutes for maintenance windows. - :type time_granularity_in_minutes: int - :param allow_multiple_maintenance_windows_per_cycle: Whether we allow multiple maintenance + :vartype maintenance_window_cycles: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] + :ivar min_duration_in_minutes: Minimum duration of maintenance window. + :vartype min_duration_in_minutes: int + :ivar default_duration_in_minutes: Default duration for maintenance window. + :vartype default_duration_in_minutes: int + :ivar min_cycles: Minimum number of maintenance windows cycles to be set on the database. + :vartype min_cycles: int + :ivar time_granularity_in_minutes: Time granularity in minutes for maintenance windows. + :vartype time_granularity_in_minutes: int + :ivar allow_multiple_maintenance_windows_per_cycle: Whether we allow multiple maintenance windows per cycle. - :type allow_multiple_maintenance_windows_per_cycle: bool + :vartype allow_multiple_maintenance_windows_per_cycle: bool """ _validation = { @@ -7128,6 +8633,24 @@ def __init__( allow_multiple_maintenance_windows_per_cycle: Optional[bool] = None, **kwargs ): + """ + :keyword is_enabled: Whether maintenance windows are enabled for the database. + :paramtype is_enabled: bool + :keyword maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\ *60}, + {Wednesday, 0, 24*\ 60}. + :paramtype maintenance_window_cycles: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] + :keyword min_duration_in_minutes: Minimum duration of maintenance window. + :paramtype min_duration_in_minutes: int + :keyword default_duration_in_minutes: Default duration for maintenance window. + :paramtype default_duration_in_minutes: int + :keyword min_cycles: Minimum number of maintenance windows cycles to be set on the database. + :paramtype min_cycles: int + :keyword time_granularity_in_minutes: Time granularity in minutes for maintenance windows. + :paramtype time_granularity_in_minutes: int + :keyword allow_multiple_maintenance_windows_per_cycle: Whether we allow multiple maintenance + windows per cycle. + :paramtype allow_multiple_maintenance_windows_per_cycle: bool + """ super(MaintenanceWindowOptions, self).__init__(**kwargs) self.is_enabled = is_enabled self.maintenance_window_cycles = maintenance_window_cycles @@ -7149,8 +8672,8 @@ class MaintenanceWindows(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param time_ranges: - :type time_ranges: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] + :ivar time_ranges: + :vartype time_ranges: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] """ _validation = { @@ -7172,6 +8695,10 @@ def __init__( time_ranges: Optional[List["MaintenanceWindowTimeRange"]] = None, **kwargs ): + """ + :keyword time_ranges: + :paramtype time_ranges: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] + """ super(MaintenanceWindows, self).__init__(**kwargs) self.time_ranges = time_ranges @@ -7179,13 +8706,13 @@ def __init__( class MaintenanceWindowTimeRange(msrest.serialization.Model): """Maintenance window time range. - :param day_of_week: Day of maintenance window. Possible values include: "Sunday", "Monday", + :ivar day_of_week: Day of maintenance window. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". - :type day_of_week: str or ~azure.mgmt.sql.models.DayOfWeek - :param start_time: Start time minutes offset from 12am. - :type start_time: str - :param duration: Duration of maintenance window in minutes. - :type duration: str + :vartype day_of_week: str or ~azure.mgmt.sql.models.DayOfWeek + :ivar start_time: Start time minutes offset from 12am. + :vartype start_time: str + :ivar duration: Duration of maintenance window in minutes. + :vartype duration: str """ _attribute_map = { @@ -7202,6 +8729,15 @@ def __init__( duration: Optional[str] = None, **kwargs ): + """ + :keyword day_of_week: Day of maintenance window. Possible values include: "Sunday", "Monday", + "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + :paramtype day_of_week: str or ~azure.mgmt.sql.models.DayOfWeek + :keyword start_time: Start time minutes offset from 12am. + :paramtype start_time: str + :keyword duration: Duration of maintenance window in minutes. + :paramtype duration: str + """ super(MaintenanceWindowTimeRange, self).__init__(**kwargs) self.day_of_week = day_of_week self.start_time = start_time @@ -7219,9 +8755,9 @@ class ManagedBackupShortTermRetentionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param retention_days: The backup retention period in days. This is how many days Point-in-Time + :ivar retention_days: The backup retention period in days. This is how many days Point-in-Time Restore will be supported. - :type retention_days: int + :vartype retention_days: int """ _validation = { @@ -7243,6 +8779,11 @@ def __init__( retention_days: Optional[int] = None, **kwargs ): + """ + :keyword retention_days: The backup retention period in days. This is how many days + Point-in-Time Restore will be supported. + :paramtype retention_days: int + """ super(ManagedBackupShortTermRetentionPolicy, self).__init__(**kwargs) self.retention_days = retention_days @@ -7272,6 +8813,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedBackupShortTermRetentionPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -7290,12 +8833,12 @@ class ManagedDatabase(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param collation: Collation of the managed database. - :type collation: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar collation: Collation of the managed database. + :vartype collation: str :ivar status: Status of the database. Possible values include: "Online", "Offline", "Shutdown", "Creating", "Inaccessible", "Restoring", "Updating". :vartype status: str or ~azure.mgmt.sql.models.ManagedDatabaseStatus @@ -7303,16 +8846,16 @@ class ManagedDatabase(TrackedResource): :vartype creation_date: ~datetime.datetime :ivar earliest_restore_point: Earliest restore point in time for point in time restore. :vartype earliest_restore_point: ~datetime.datetime - :param restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is + :ivar restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime + :vartype restore_point_in_time: ~datetime.datetime :ivar default_secondary_location: Geo paired region. :vartype default_secondary_location: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: + :ivar catalog_collation: Collation of the metadata catalog. Possible values include: "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param create_mode: Managed database create mode. PointInTimeRestore: Create a database by + :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :ivar create_mode: Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and @@ -7322,33 +8865,32 @@ class ManagedDatabase(TrackedResource): long term retention backup (longTermRetentionBackupResourceId required). Possible values include: "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", "RestoreLongTermRetentionBackup". - :type create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :param storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value - is required. Specifies the uri of the storage container where backups for this restore are - stored. - :type storage_container_uri: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str - :param restorable_dropped_database_id: The restorable dropped database resource id to restore + :vartype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode + :ivar storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value is + required. Specifies the uri of the storage container where backups for this restore are stored. + :vartype storage_container_uri: str + :ivar source_database_id: The resource identifier of the source database associated with create + operation of this database. + :vartype source_database_id: str + :ivar restorable_dropped_database_id: The restorable dropped database resource id to restore when creating this database. - :type restorable_dropped_database_id: str - :param storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this + :vartype restorable_dropped_database_id: str + :ivar storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. - :type storage_container_sas_token: str + :vartype storage_container_sas_token: str :ivar failover_group_id: Instance Failover Group resource identifier that this managed database belongs to. :vartype failover_group_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated + :ivar recoverable_database_id: The resource identifier of the recoverable database associated with create operation of this database. - :type recoverable_database_id: str - :param long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be + :vartype recoverable_database_id: str + :ivar long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be used for restore of this managed database. - :type long_term_retention_backup_resource_id: str - :param auto_complete_restore: Whether to auto complete restore of this managed database. - :type auto_complete_restore: bool - :param last_backup_name: Last backup file name for restore of this managed database. - :type last_backup_name: str + :vartype long_term_retention_backup_resource_id: str + :ivar auto_complete_restore: Whether to auto complete restore of this managed database. + :vartype auto_complete_restore: bool + :ivar last_backup_name: Last backup file name for restore of this managed database. + :vartype last_backup_name: str """ _validation = { @@ -7407,6 +8949,55 @@ def __init__( last_backup_name: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword collation: Collation of the managed database. + :paramtype collation: str + :keyword restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is + required. Specifies the point in time (ISO8601 format) of the source database that will be + restored to create the new database. + :paramtype restore_point_in_time: ~datetime.datetime + :keyword catalog_collation: Collation of the metadata catalog. Possible values include: + "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". + :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :keyword create_mode: Managed database create mode. PointInTimeRestore: Create a database by + restoring a point in time backup of an existing database. SourceDatabaseName, + SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a + database by restoring from external backup files. Collation, StorageContainerUri and + StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a + geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database + resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a + long term retention backup (longTermRetentionBackupResourceId required). Possible values + include: "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", + "RestoreLongTermRetentionBackup". + :paramtype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode + :keyword storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value + is required. Specifies the uri of the storage container where backups for this restore are + stored. + :paramtype storage_container_uri: str + :keyword source_database_id: The resource identifier of the source database associated with + create operation of this database. + :paramtype source_database_id: str + :keyword restorable_dropped_database_id: The restorable dropped database resource id to restore + when creating this database. + :paramtype restorable_dropped_database_id: str + :keyword storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this + value is required. Specifies the storage container sas token. + :paramtype storage_container_sas_token: str + :keyword recoverable_database_id: The resource identifier of the recoverable database + associated with create operation of this database. + :paramtype recoverable_database_id: str + :keyword long_term_retention_backup_resource_id: The name of the Long Term Retention backup to + be used for restore of this managed database. + :paramtype long_term_retention_backup_resource_id: str + :keyword auto_complete_restore: Whether to auto complete restore of this managed database. + :paramtype auto_complete_restore: bool + :keyword last_backup_name: Last backup file name for restore of this managed database. + :paramtype last_backup_name: str + """ super(ManagedDatabase, self).__init__(location=location, tags=tags, **kwargs) self.collation = collation self.status = None @@ -7452,6 +9043,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedDatabaseListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -7526,6 +9119,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedDatabaseRestoreDetailsResult, self).__init__(**kwargs) self.status = None self.current_restoring_file_name = None @@ -7550,27 +9145,27 @@ class ManagedDatabaseSecurityAlertPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy + :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. Possible values include: "New", "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertPolicyState + :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype disabled_alerts: list[str] + :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :vartype email_addresses: list[str] + :ivar email_account_admins: Specifies that the alert is sent to the account administrators. + :vartype email_account_admins: bool + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int + :vartype storage_account_access_key: str + :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. + :vartype retention_days: int :ivar creation_time: Specifies the UTC creation time of the policy. :vartype creation_time: ~datetime.datetime """ @@ -7608,6 +9203,30 @@ def __init__( retention_days: Optional[int] = None, **kwargs ): + """ + :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a + policy has not been applied yet on the specific database. Possible values include: "New", + "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertPolicyState + :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, + Brute_Force. + :paramtype disabled_alerts: list[str] + :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :paramtype email_addresses: list[str] + :keyword email_account_admins: Specifies that the alert is sent to the account administrators. + :paramtype email_account_admins: bool + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection + audit logs. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit + storage account. + :paramtype storage_account_access_key: str + :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit + logs. + :paramtype retention_days: int + """ super(ManagedDatabaseSecurityAlertPolicy, self).__init__(**kwargs) self.state = state self.disabled_alerts = disabled_alerts @@ -7644,6 +9263,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedDatabaseSecurityAlertPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -7654,10 +9275,10 @@ class ManagedDatabaseUpdate(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param collation: Collation of the managed database. - :type collation: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar collation: Collation of the managed database. + :vartype collation: str :ivar status: Status of the database. Possible values include: "Online", "Offline", "Shutdown", "Creating", "Inaccessible", "Restoring", "Updating". :vartype status: str or ~azure.mgmt.sql.models.ManagedDatabaseStatus @@ -7665,16 +9286,16 @@ class ManagedDatabaseUpdate(msrest.serialization.Model): :vartype creation_date: ~datetime.datetime :ivar earliest_restore_point: Earliest restore point in time for point in time restore. :vartype earliest_restore_point: ~datetime.datetime - :param restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is + :ivar restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime + :vartype restore_point_in_time: ~datetime.datetime :ivar default_secondary_location: Geo paired region. :vartype default_secondary_location: str - :param catalog_collation: Collation of the metadata catalog. Possible values include: + :ivar catalog_collation: Collation of the metadata catalog. Possible values include: "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". - :type catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :param create_mode: Managed database create mode. PointInTimeRestore: Create a database by + :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :ivar create_mode: Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and @@ -7684,33 +9305,32 @@ class ManagedDatabaseUpdate(msrest.serialization.Model): long term retention backup (longTermRetentionBackupResourceId required). Possible values include: "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", "RestoreLongTermRetentionBackup". - :type create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :param storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value - is required. Specifies the uri of the storage container where backups for this restore are - stored. - :type storage_container_uri: str - :param source_database_id: The resource identifier of the source database associated with - create operation of this database. - :type source_database_id: str - :param restorable_dropped_database_id: The restorable dropped database resource id to restore + :vartype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode + :ivar storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value is + required. Specifies the uri of the storage container where backups for this restore are stored. + :vartype storage_container_uri: str + :ivar source_database_id: The resource identifier of the source database associated with create + operation of this database. + :vartype source_database_id: str + :ivar restorable_dropped_database_id: The restorable dropped database resource id to restore when creating this database. - :type restorable_dropped_database_id: str - :param storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this + :vartype restorable_dropped_database_id: str + :ivar storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. - :type storage_container_sas_token: str + :vartype storage_container_sas_token: str :ivar failover_group_id: Instance Failover Group resource identifier that this managed database belongs to. :vartype failover_group_id: str - :param recoverable_database_id: The resource identifier of the recoverable database associated + :ivar recoverable_database_id: The resource identifier of the recoverable database associated with create operation of this database. - :type recoverable_database_id: str - :param long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be + :vartype recoverable_database_id: str + :ivar long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be used for restore of this managed database. - :type long_term_retention_backup_resource_id: str - :param auto_complete_restore: Whether to auto complete restore of this managed database. - :type auto_complete_restore: bool - :param last_backup_name: Last backup file name for restore of this managed database. - :type last_backup_name: str + :vartype long_term_retention_backup_resource_id: str + :ivar auto_complete_restore: Whether to auto complete restore of this managed database. + :vartype auto_complete_restore: bool + :ivar last_backup_name: Last backup file name for restore of this managed database. + :vartype last_backup_name: str """ _validation = { @@ -7760,6 +9380,53 @@ def __init__( last_backup_name: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword collation: Collation of the managed database. + :paramtype collation: str + :keyword restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is + required. Specifies the point in time (ISO8601 format) of the source database that will be + restored to create the new database. + :paramtype restore_point_in_time: ~datetime.datetime + :keyword catalog_collation: Collation of the metadata catalog. Possible values include: + "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS". + :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :keyword create_mode: Managed database create mode. PointInTimeRestore: Create a database by + restoring a point in time backup of an existing database. SourceDatabaseName, + SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a + database by restoring from external backup files. Collation, StorageContainerUri and + StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a + geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database + resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a + long term retention backup (longTermRetentionBackupResourceId required). Possible values + include: "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", + "RestoreLongTermRetentionBackup". + :paramtype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode + :keyword storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value + is required. Specifies the uri of the storage container where backups for this restore are + stored. + :paramtype storage_container_uri: str + :keyword source_database_id: The resource identifier of the source database associated with + create operation of this database. + :paramtype source_database_id: str + :keyword restorable_dropped_database_id: The restorable dropped database resource id to restore + when creating this database. + :paramtype restorable_dropped_database_id: str + :keyword storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup, this + value is required. Specifies the storage container sas token. + :paramtype storage_container_sas_token: str + :keyword recoverable_database_id: The resource identifier of the recoverable database + associated with create operation of this database. + :paramtype recoverable_database_id: str + :keyword long_term_retention_backup_resource_id: The name of the Long Term Retention backup to + be used for restore of this managed database. + :paramtype long_term_retention_backup_resource_id: str + :keyword auto_complete_restore: Whether to auto complete restore of this managed database. + :paramtype auto_complete_restore: bool + :keyword last_backup_name: Last backup file name for restore of this managed database. + :paramtype last_backup_name: str + """ super(ManagedDatabaseUpdate, self).__init__(**kwargs) self.tags = tags self.collation = collation @@ -7794,68 +9461,68 @@ class ManagedInstance(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: The Azure Active Directory identity of the managed instance. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity - :param sku: Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar identity: The Azure Active Directory identity of the managed instance. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar sku: Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, BC_Gen5. - :type sku: ~azure.mgmt.sql.models.Sku - :ivar provisioning_state: Possible values include: "Creating", "Deleting", "Updating", + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar provisioning_state: Possible values include: "Creating", "Deleting", "Updating", "Unknown", "Succeeded", "Failed", "Accepted", "Created", "Deleted", "Unrecognized", "Running", "Canceled", "NotSpecified", "Registering", "TimedOut". :vartype provisioning_state: str or ~azure.mgmt.sql.models.ManagedInstancePropertiesProvisioningState - :param managed_instance_create_mode: Specifies the mode of database creation. + :ivar managed_instance_create_mode: Specifies the mode of database creation. Default: Regular instance creation. Restore: Creates an instance by restoring a set of backups to specific point in time. RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: "Default", "PointInTimeRestore". - :type managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode + :vartype managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode :ivar fully_qualified_domain_name: The fully qualified domain name of the managed instance. :vartype fully_qualified_domain_name: str - :param administrator_login: Administrator username for the managed instance. Can only be + :ivar administrator_login: Administrator username for the managed instance. Can only be specified when the managed instance is being created (and is required for creation). - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for managed + :vartype administrator_login: str + :ivar administrator_login_password: The administrator login password (required for managed instance creation). - :type administrator_login_password: str - :param subnet_id: Subnet resource ID for the managed instance. - :type subnet_id: str + :vartype administrator_login_password: str + :ivar subnet_id: Subnet resource ID for the managed instance. + :vartype subnet_id: str :ivar state: The state of the managed instance. :vartype state: str - :param license_type: The license type. Possible values are 'LicenseIncluded' (regular price + :ivar license_type: The license type. Possible values are 'LicenseIncluded' (regular price inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType - :param v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. - :type v_cores: int - :param storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. + :vartype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :ivar v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. + :vartype v_cores: int + :ivar storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. Increments of 32 GB allowed only. - :type storage_size_in_gb: int - :param collation: Collation of the managed instance. - :type collation: str + :vartype storage_size_in_gb: int + :ivar collation: Collation of the managed instance. + :vartype collation: str :ivar dns_zone: The Dns Zone that the managed instance is in. :vartype dns_zone: str - :param dns_zone_partner: The resource id of another managed instance whose DNS zone this - managed instance will share after creation. - :type dns_zone_partner: str - :param public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :type public_data_endpoint_enabled: bool - :param source_managed_instance_id: The resource identifier of the source managed instance + :ivar dns_zone_partner: The resource id of another managed instance whose DNS zone this managed + instance will share after creation. + :vartype dns_zone_partner: str + :ivar public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. + :vartype public_data_endpoint_enabled: bool + :ivar source_managed_instance_id: The resource identifier of the source managed instance associated with create operation of this instance. - :type source_managed_instance_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + :vartype source_managed_instance_id: str + :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param proxy_override: Connection type used for connecting to the instance. Possible values + :vartype restore_point_in_time: ~datetime.datetime + :ivar proxy_override: Connection type used for connecting to the instance. Possible values include: "Proxy", "Redirect", "Default". - :type proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :param timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. + :vartype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride + :ivar timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. Windows keeps details on supported timezones, including the id, in registry under KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM @@ -7863,39 +9530,39 @@ class ManagedInstance(TrackedResource): List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :type timezone_id: str - :param instance_pool_id: The Id of the instance pool this managed server belongs to. - :type instance_pool_id: str - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this + :vartype timezone_id: str + :ivar instance_pool_id: The Id of the instance pool this managed server belongs to. + :vartype instance_pool_id: str + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this managed instance. - :type maintenance_configuration_id: str + :vartype maintenance_configuration_id: str :ivar private_endpoint_connections: List of private endpoint connections on a managed instance. :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ManagedInstancePecProperty] - :param minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :type minimal_tls_version: str + :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. + :vartype minimal_tls_version: str :ivar current_backup_storage_redundancy: The storage account type used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: "Geo", "Local", "Zone", "GeoZone". :vartype current_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this instance. The options are Local (LocallyRedundantStorage), Zone + :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups + for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or + :vartype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param zone_redundant: Whether or not the multi-az is enabled. - :type zone_redundant: bool - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory administrator of the server. - :type administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :param service_principal: The managed instance's service principal. - :type service_principal: ~azure.mgmt.sql.models.ServicePrincipal + :ivar zone_redundant: Whether or not the multi-az is enabled. + :vartype zone_redundant: bool + :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used + by default. + :vartype primary_user_assigned_identity_id: str + :ivar key_id: A CMK URI of the key to use for encryption. + :vartype key_id: str + :ivar administrators: The Azure Active Directory administrator of the server. + :vartype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator + :ivar service_principal: The managed instance's service principal. + :vartype service_principal: ~azure.mgmt.sql.models.ServicePrincipal """ _validation = { @@ -7982,6 +9649,91 @@ def __init__( service_principal: Optional["ServicePrincipal"] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: The Azure Active Directory identity of the managed instance. + :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity + :keyword sku: Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, + BC_Gen5. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword managed_instance_create_mode: Specifies the mode of database creation. + + Default: Regular instance creation. + + Restore: Creates an instance by restoring a set of backups to specific point in time. + RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: + "Default", "PointInTimeRestore". + :paramtype managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode + :keyword administrator_login: Administrator username for the managed instance. Can only be + specified when the managed instance is being created (and is required for creation). + :paramtype administrator_login: str + :keyword administrator_login_password: The administrator login password (required for managed + instance creation). + :paramtype administrator_login_password: str + :keyword subnet_id: Subnet resource ID for the managed instance. + :paramtype subnet_id: str + :keyword license_type: The license type. Possible values are 'LicenseIncluded' (regular price + inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL + licenses). Possible values include: "LicenseIncluded", "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :keyword v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. + :paramtype v_cores: int + :keyword storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. + Increments of 32 GB allowed only. + :paramtype storage_size_in_gb: int + :keyword collation: Collation of the managed instance. + :paramtype collation: str + :keyword dns_zone_partner: The resource id of another managed instance whose DNS zone this + managed instance will share after creation. + :paramtype dns_zone_partner: str + :keyword public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. + :paramtype public_data_endpoint_enabled: bool + :keyword source_managed_instance_id: The resource identifier of the source managed instance + associated with create operation of this instance. + :paramtype source_managed_instance_id: str + :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + database that will be restored to create the new database. + :paramtype restore_point_in_time: ~datetime.datetime + :keyword proxy_override: Connection type used for connecting to the instance. Possible values + include: "Proxy", "Redirect", "Default". + :paramtype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride + :keyword timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. + Windows keeps details on supported timezones, including the id, in registry under + KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. + You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM + sys.time_zone_info. + List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in + PowerShell. + An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". + :paramtype timezone_id: str + :keyword instance_pool_id: The Id of the instance pool this managed server belongs to. + :paramtype instance_pool_id: str + :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :paramtype maintenance_configuration_id: str + :keyword minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. + :paramtype minimal_tls_version: str + :keyword requested_backup_storage_redundancy: The storage account type to be used to store + backups for this instance. The options are Local (LocallyRedundantStorage), Zone + (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). + Possible values include: "Geo", "Local", "Zone", "GeoZone". + :paramtype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :keyword zone_redundant: Whether or not the multi-az is enabled. + :paramtype zone_redundant: bool + :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be + used by default. + :paramtype primary_user_assigned_identity_id: str + :keyword key_id: A CMK URI of the key to use for encryption. + :paramtype key_id: str + :keyword administrators: The Azure Active Directory administrator of the server. + :paramtype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator + :keyword service_principal: The managed instance's service principal. + :paramtype service_principal: ~azure.mgmt.sql.models.ServicePrincipal + """ super(ManagedInstance, self).__init__(location=location, tags=tags, **kwargs) self.identity = identity self.sku = sku @@ -8027,15 +9779,15 @@ class ManagedInstanceAdministrator(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param administrator_type: Type of the managed instance administrator. Possible values include: + :ivar administrator_type: Type of the managed instance administrator. Possible values include: "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.ManagedInstanceAdministratorType - :param login: Login name of the managed instance administrator. - :type login: str - :param sid: SID (object ID) of the managed instance administrator. - :type sid: str - :param tenant_id: Tenant ID of the managed instance administrator. - :type tenant_id: str + :vartype administrator_type: str or ~azure.mgmt.sql.models.ManagedInstanceAdministratorType + :ivar login: Login name of the managed instance administrator. + :vartype login: str + :ivar sid: SID (object ID) of the managed instance administrator. + :vartype sid: str + :ivar tenant_id: Tenant ID of the managed instance administrator. + :vartype tenant_id: str """ _validation = { @@ -8063,6 +9815,17 @@ def __init__( tenant_id: Optional[str] = None, **kwargs ): + """ + :keyword administrator_type: Type of the managed instance administrator. Possible values + include: "ActiveDirectory". + :paramtype administrator_type: str or ~azure.mgmt.sql.models.ManagedInstanceAdministratorType + :keyword login: Login name of the managed instance administrator. + :paramtype login: str + :keyword sid: SID (object ID) of the managed instance administrator. + :paramtype sid: str + :keyword tenant_id: Tenant ID of the managed instance administrator. + :paramtype tenant_id: str + """ super(ManagedInstanceAdministrator, self).__init__(**kwargs) self.administrator_type = administrator_type self.login = login @@ -8095,6 +9858,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceAdministratorListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8111,8 +9876,8 @@ class ManagedInstanceAzureADOnlyAuthentication(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :vartype azure_ad_only_authentication: bool """ _validation = { @@ -8134,6 +9899,10 @@ def __init__( azure_ad_only_authentication: Optional[bool] = None, **kwargs ): + """ + :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :paramtype azure_ad_only_authentication: bool + """ super(ManagedInstanceAzureADOnlyAuthentication, self).__init__(**kwargs) self.azure_ad_only_authentication = azure_ad_only_authentication @@ -8163,6 +9932,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceAzureADOnlyAuthListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8185,8 +9956,8 @@ class ManagedInstanceEditionCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -8212,6 +9983,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ManagedInstanceEditionCapability, self).__init__(**kwargs) self.name = None self.supported_families = None @@ -8235,17 +10010,17 @@ class ManagedInstanceEncryptionProtector(ProxyResource): :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal experience. :vartype kind: str - :param server_key_name: The name of the managed instance key. - :type server_key_name: str - :param server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. + :ivar server_key_name: The name of the managed instance key. + :vartype server_key_name: str + :ivar server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType :ivar uri: The URI of the server key. :vartype uri: str :ivar thumbprint: Thumbprint of the server key. :vartype thumbprint: str - :param auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :type auto_rotation_enabled: bool + :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :vartype auto_rotation_enabled: bool """ _validation = { @@ -8277,6 +10052,15 @@ def __init__( auto_rotation_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword server_key_name: The name of the managed instance key. + :paramtype server_key_name: str + :keyword server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. + Possible values include: "ServiceManaged", "AzureKeyVault". + :paramtype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :keyword auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :paramtype auto_rotation_enabled: bool + """ super(ManagedInstanceEncryptionProtector, self).__init__(**kwargs) self.kind = None self.server_key_name = server_key_name @@ -8311,6 +10095,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceEncryptionProtectorListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8319,20 +10105,20 @@ def __init__( class ManagedInstanceExternalAdministrator(msrest.serialization.Model): """Properties of a active directory administrator. - :param administrator_type: Type of the sever administrator. Possible values include: + :ivar administrator_type: Type of the sever administrator. Possible values include: "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :param principal_type: Principal Type of the sever administrator. Possible values include: + :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :ivar principal_type: Principal Type of the sever administrator. Possible values include: "User", "Group", "Application". - :type principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :param login: Login name of the server administrator. - :type login: str - :param sid: SID (object ID) of the server administrator. - :type sid: str - :param tenant_id: Tenant ID of the administrator. - :type tenant_id: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool + :vartype principal_type: str or ~azure.mgmt.sql.models.PrincipalType + :ivar login: Login name of the server administrator. + :vartype login: str + :ivar sid: SID (object ID) of the server administrator. + :vartype sid: str + :ivar tenant_id: Tenant ID of the administrator. + :vartype tenant_id: str + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :vartype azure_ad_only_authentication: bool """ _attribute_map = { @@ -8355,6 +10141,22 @@ def __init__( azure_ad_only_authentication: Optional[bool] = None, **kwargs ): + """ + :keyword administrator_type: Type of the sever administrator. Possible values include: + "ActiveDirectory". + :paramtype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :keyword principal_type: Principal Type of the sever administrator. Possible values include: + "User", "Group", "Application". + :paramtype principal_type: str or ~azure.mgmt.sql.models.PrincipalType + :keyword login: Login name of the server administrator. + :paramtype login: str + :keyword sid: SID (object ID) of the server administrator. + :paramtype sid: str + :keyword tenant_id: Tenant ID of the administrator. + :paramtype tenant_id: str + :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :paramtype azure_ad_only_authentication: bool + """ super(ManagedInstanceExternalAdministrator, self).__init__(**kwargs) self.administrator_type = administrator_type self.principal_type = principal_type @@ -8380,8 +10182,8 @@ class ManagedInstanceFamilyCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -8407,6 +10209,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ManagedInstanceFamilyCapability, self).__init__(**kwargs) self.name = None self.sku = None @@ -8430,12 +10236,11 @@ class ManagedInstanceKey(ProxyResource): :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal experience. :vartype kind: str - :param server_key_type: The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values + :ivar server_key_type: The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :param uri: The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is - required. - :type uri: str + :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :ivar uri: The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. + :vartype uri: str :ivar thumbprint: Thumbprint of the key. :vartype thumbprint: str :ivar creation_date: The key creation date. @@ -8473,6 +10278,14 @@ def __init__( uri: Optional[str] = None, **kwargs ): + """ + :keyword server_key_type: The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values + include: "ServiceManaged", "AzureKeyVault". + :paramtype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :keyword uri: The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is + required. + :paramtype uri: str + """ super(ManagedInstanceKey, self).__init__(**kwargs) self.kind = None self.server_key_type = server_key_type @@ -8507,6 +10320,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceKeyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8537,6 +10352,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8600,6 +10417,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceLongTermRetentionBackup, self).__init__(**kwargs) self.managed_instance_name = None self.managed_instance_create_time = None @@ -8635,6 +10454,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceLongTermRetentionBackupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8651,14 +10472,14 @@ class ManagedInstanceLongTermRetentionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :type weekly_retention: str - :param monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. - :type monthly_retention: str - :param yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :type yearly_retention: str - :param week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :type week_of_year: int + :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :vartype weekly_retention: str + :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. + :vartype monthly_retention: str + :ivar yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :vartype yearly_retention: str + :ivar week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :vartype week_of_year: int """ _validation = { @@ -8686,6 +10507,17 @@ def __init__( week_of_year: Optional[int] = None, **kwargs ): + """ + :keyword weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :paramtype weekly_retention: str + :keyword monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 + format. + :paramtype monthly_retention: str + :keyword yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :paramtype yearly_retention: str + :keyword week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :paramtype week_of_year: int + """ super(ManagedInstanceLongTermRetentionPolicy, self).__init__(**kwargs) self.weekly_retention = weekly_retention self.monthly_retention = monthly_retention @@ -8718,6 +10550,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceLongTermRetentionPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8733,8 +10567,8 @@ class ManagedInstanceMaintenanceConfigurationCapability(msrest.serialization.Mod :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -8754,6 +10588,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ManagedInstanceMaintenanceConfigurationCapability, self).__init__(**kwargs) self.name = None self.status = None @@ -8851,6 +10689,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceOperation, self).__init__(**kwargs) self.managed_instance_name = None self.operation = None @@ -8894,6 +10734,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceOperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -8924,6 +10766,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceOperationParametersPair, self).__init__(**kwargs) self.current_parameters = None self.requested_parameters = None @@ -8958,6 +10802,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceOperationSteps, self).__init__(**kwargs) self.total_steps = None self.current_step = None @@ -8967,10 +10813,10 @@ def __init__( class ManagedInstancePairInfo(msrest.serialization.Model): """Pairs of Managed Instances in the failover group. - :param primary_managed_instance_id: Id of Primary Managed Instance in pair. - :type primary_managed_instance_id: str - :param partner_managed_instance_id: Id of Partner Managed Instance in pair. - :type partner_managed_instance_id: str + :ivar primary_managed_instance_id: Id of Primary Managed Instance in pair. + :vartype primary_managed_instance_id: str + :ivar partner_managed_instance_id: Id of Partner Managed Instance in pair. + :vartype partner_managed_instance_id: str """ _attribute_map = { @@ -8985,6 +10831,12 @@ def __init__( partner_managed_instance_id: Optional[str] = None, **kwargs ): + """ + :keyword primary_managed_instance_id: Id of Primary Managed Instance in pair. + :paramtype primary_managed_instance_id: str + :keyword partner_managed_instance_id: Id of Partner Managed Instance in pair. + :paramtype partner_managed_instance_id: str + """ super(ManagedInstancePairInfo, self).__init__(**kwargs) self.primary_managed_instance_id = primary_managed_instance_id self.partner_managed_instance_id = partner_managed_instance_id @@ -9015,6 +10867,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstancePecProperty, self).__init__(**kwargs) self.id = None self.properties = None @@ -9031,11 +10885,11 @@ class ManagedInstancePrivateEndpointConnection(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :param private_link_service_connection_state: Connection State of the Private Endpoint + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty + :ivar private_link_service_connection_state: Connection State of the Private Endpoint Connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the Private Endpoint Connection. :vartype provisioning_state: str @@ -9064,6 +10918,14 @@ def __init__( private_link_service_connection_state: Optional["ManagedInstancePrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty + :keyword private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty + """ super(ManagedInstancePrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -9095,6 +10957,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstancePrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -9105,11 +10969,11 @@ class ManagedInstancePrivateEndpointConnectionProperties(msrest.serialization.Mo Variables are only populated by the server, and will be ignored when sending a request. - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :param private_link_service_connection_state: Connection State of the Private Endpoint + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty + :ivar private_link_service_connection_state: Connection State of the Private Endpoint Connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the Private Endpoint Connection. :vartype provisioning_state: str @@ -9132,6 +10996,14 @@ def __init__( private_link_service_connection_state: Optional["ManagedInstancePrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty + :keyword private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty + """ super(ManagedInstancePrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -9141,8 +11013,8 @@ def __init__( class ManagedInstancePrivateEndpointProperty(msrest.serialization.Model): """ManagedInstancePrivateEndpointProperty. - :param id: Resource id of the private endpoint. - :type id: str + :ivar id: Resource id of the private endpoint. + :vartype id: str """ _attribute_map = { @@ -9155,6 +11027,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource id of the private endpoint. + :paramtype id: str + """ super(ManagedInstancePrivateEndpointProperty, self).__init__(**kwargs) self.id = id @@ -9192,6 +11068,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstancePrivateLink, self).__init__(**kwargs) self.properties = None @@ -9221,6 +11099,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstancePrivateLinkListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -9251,6 +11131,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstancePrivateLinkProperties, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -9263,10 +11145,10 @@ class ManagedInstancePrivateLinkServiceConnectionStateProperty(msrest.serializat All required parameters must be populated in order to send to Azure. - :param status: Required. The private link service connection status. - :type status: str - :param description: Required. The private link service connection description. - :type description: str + :ivar status: Required. The private link service connection status. + :vartype status: str + :ivar description: Required. The private link service connection description. + :vartype description: str :ivar actions_required: The private link service connection description. :vartype actions_required: str """ @@ -9290,6 +11172,12 @@ def __init__( description: str, **kwargs ): + """ + :keyword status: Required. The private link service connection status. + :paramtype status: str + :keyword description: Required. The private link service connection description. + :paramtype description: str + """ super(ManagedInstancePrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) self.status = status self.description = description @@ -9307,8 +11195,8 @@ class ManagedInstanceQuery(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param query_text: Query text. - :type query_text: str + :ivar query_text: Query text. + :vartype query_text: str """ _validation = { @@ -9330,6 +11218,10 @@ def __init__( query_text: Optional[str] = None, **kwargs ): + """ + :keyword query_text: Query text. + :paramtype query_text: str + """ super(ManagedInstanceQuery, self).__init__(**kwargs) self.query_text = query_text @@ -9359,6 +11251,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceQueryStatistics, self).__init__(**kwargs) self.value = None self.next_link = None @@ -9369,65 +11263,65 @@ class ManagedInstanceUpdate(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param sku: Managed instance sku. - :type sku: ~azure.mgmt.sql.models.Sku - :param identity: Managed instance identity. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar provisioning_state: Possible values include: "Creating", "Deleting", "Updating", + :ivar sku: Managed instance sku. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar identity: Managed instance identity. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar provisioning_state: Possible values include: "Creating", "Deleting", "Updating", "Unknown", "Succeeded", "Failed", "Accepted", "Created", "Deleted", "Unrecognized", "Running", "Canceled", "NotSpecified", "Registering", "TimedOut". :vartype provisioning_state: str or ~azure.mgmt.sql.models.ManagedInstancePropertiesProvisioningState - :param managed_instance_create_mode: Specifies the mode of database creation. + :ivar managed_instance_create_mode: Specifies the mode of database creation. Default: Regular instance creation. Restore: Creates an instance by restoring a set of backups to specific point in time. RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: "Default", "PointInTimeRestore". - :type managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode + :vartype managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode :ivar fully_qualified_domain_name: The fully qualified domain name of the managed instance. :vartype fully_qualified_domain_name: str - :param administrator_login: Administrator username for the managed instance. Can only be + :ivar administrator_login: Administrator username for the managed instance. Can only be specified when the managed instance is being created (and is required for creation). - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for managed + :vartype administrator_login: str + :ivar administrator_login_password: The administrator login password (required for managed instance creation). - :type administrator_login_password: str - :param subnet_id: Subnet resource ID for the managed instance. - :type subnet_id: str + :vartype administrator_login_password: str + :ivar subnet_id: Subnet resource ID for the managed instance. + :vartype subnet_id: str :ivar state: The state of the managed instance. :vartype state: str - :param license_type: The license type. Possible values are 'LicenseIncluded' (regular price + :ivar license_type: The license type. Possible values are 'LicenseIncluded' (regular price inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Possible values include: "LicenseIncluded", "BasePrice". - :type license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType - :param v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. - :type v_cores: int - :param storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. + :vartype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :ivar v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. + :vartype v_cores: int + :ivar storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. Increments of 32 GB allowed only. - :type storage_size_in_gb: int - :param collation: Collation of the managed instance. - :type collation: str + :vartype storage_size_in_gb: int + :ivar collation: Collation of the managed instance. + :vartype collation: str :ivar dns_zone: The Dns Zone that the managed instance is in. :vartype dns_zone: str - :param dns_zone_partner: The resource id of another managed instance whose DNS zone this - managed instance will share after creation. - :type dns_zone_partner: str - :param public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :type public_data_endpoint_enabled: bool - :param source_managed_instance_id: The resource identifier of the source managed instance + :ivar dns_zone_partner: The resource id of another managed instance whose DNS zone this managed + instance will share after creation. + :vartype dns_zone_partner: str + :ivar public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. + :vartype public_data_endpoint_enabled: bool + :ivar source_managed_instance_id: The resource identifier of the source managed instance associated with create operation of this instance. - :type source_managed_instance_id: str - :param restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + :vartype source_managed_instance_id: str + :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. - :type restore_point_in_time: ~datetime.datetime - :param proxy_override: Connection type used for connecting to the instance. Possible values + :vartype restore_point_in_time: ~datetime.datetime + :ivar proxy_override: Connection type used for connecting to the instance. Possible values include: "Proxy", "Redirect", "Default". - :type proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :param timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. + :vartype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride + :ivar timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. Windows keeps details on supported timezones, including the id, in registry under KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM @@ -9435,39 +11329,39 @@ class ManagedInstanceUpdate(msrest.serialization.Model): List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :type timezone_id: str - :param instance_pool_id: The Id of the instance pool this managed server belongs to. - :type instance_pool_id: str - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this + :vartype timezone_id: str + :ivar instance_pool_id: The Id of the instance pool this managed server belongs to. + :vartype instance_pool_id: str + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this managed instance. - :type maintenance_configuration_id: str + :vartype maintenance_configuration_id: str :ivar private_endpoint_connections: List of private endpoint connections on a managed instance. :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ManagedInstancePecProperty] - :param minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :type minimal_tls_version: str + :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. + :vartype minimal_tls_version: str :ivar current_backup_storage_redundancy: The storage account type used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: "Geo", "Local", "Zone", "GeoZone". :vartype current_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param requested_backup_storage_redundancy: The storage account type to be used to store - backups for this instance. The options are Local (LocallyRedundantStorage), Zone + :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups + for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or + :vartype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :param zone_redundant: Whether or not the multi-az is enabled. - :type zone_redundant: bool - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory administrator of the server. - :type administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :param service_principal: The managed instance's service principal. - :type service_principal: ~azure.mgmt.sql.models.ServicePrincipal + :ivar zone_redundant: Whether or not the multi-az is enabled. + :vartype zone_redundant: bool + :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used + by default. + :vartype primary_user_assigned_identity_id: str + :ivar key_id: A CMK URI of the key to use for encryption. + :vartype key_id: str + :ivar administrators: The Azure Active Directory administrator of the server. + :vartype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator + :ivar service_principal: The managed instance's service principal. + :vartype service_principal: ~azure.mgmt.sql.models.ServicePrincipal """ _validation = { @@ -9545,6 +11439,88 @@ def __init__( service_principal: Optional["ServicePrincipal"] = None, **kwargs ): + """ + :keyword sku: Managed instance sku. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword identity: Managed instance identity. + :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_instance_create_mode: Specifies the mode of database creation. + + Default: Regular instance creation. + + Restore: Creates an instance by restoring a set of backups to specific point in time. + RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: + "Default", "PointInTimeRestore". + :paramtype managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode + :keyword administrator_login: Administrator username for the managed instance. Can only be + specified when the managed instance is being created (and is required for creation). + :paramtype administrator_login: str + :keyword administrator_login_password: The administrator login password (required for managed + instance creation). + :paramtype administrator_login_password: str + :keyword subnet_id: Subnet resource ID for the managed instance. + :paramtype subnet_id: str + :keyword license_type: The license type. Possible values are 'LicenseIncluded' (regular price + inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL + licenses). Possible values include: "LicenseIncluded", "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :keyword v_cores: The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. + :paramtype v_cores: int + :keyword storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 8192. + Increments of 32 GB allowed only. + :paramtype storage_size_in_gb: int + :keyword collation: Collation of the managed instance. + :paramtype collation: str + :keyword dns_zone_partner: The resource id of another managed instance whose DNS zone this + managed instance will share after creation. + :paramtype dns_zone_partner: str + :keyword public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. + :paramtype public_data_endpoint_enabled: bool + :keyword source_managed_instance_id: The resource identifier of the source managed instance + associated with create operation of this instance. + :paramtype source_managed_instance_id: str + :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + database that will be restored to create the new database. + :paramtype restore_point_in_time: ~datetime.datetime + :keyword proxy_override: Connection type used for connecting to the instance. Possible values + include: "Proxy", "Redirect", "Default". + :paramtype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride + :keyword timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. + Windows keeps details on supported timezones, including the id, in registry under + KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. + You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM + sys.time_zone_info. + List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in + PowerShell. + An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". + :paramtype timezone_id: str + :keyword instance_pool_id: The Id of the instance pool this managed server belongs to. + :paramtype instance_pool_id: str + :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :paramtype maintenance_configuration_id: str + :keyword minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. + :paramtype minimal_tls_version: str + :keyword requested_backup_storage_redundancy: The storage account type to be used to store + backups for this instance. The options are Local (LocallyRedundantStorage), Zone + (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). + Possible values include: "Geo", "Local", "Zone", "GeoZone". + :paramtype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :keyword zone_redundant: Whether or not the multi-az is enabled. + :paramtype zone_redundant: bool + :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be + used by default. + :paramtype primary_user_assigned_identity_id: str + :keyword key_id: A CMK URI of the key to use for encryption. + :paramtype key_id: str + :keyword administrators: The Azure Active Directory administrator of the server. + :paramtype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator + :keyword service_principal: The managed instance's service principal. + :paramtype service_principal: ~azure.mgmt.sql.models.ServicePrincipal + """ super(ManagedInstanceUpdate, self).__init__(**kwargs) self.sku = sku self.identity = identity @@ -9605,8 +11581,8 @@ class ManagedInstanceVcoresCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -9638,6 +11614,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ManagedInstanceVcoresCapability, self).__init__(**kwargs) self.name = None self.value = None @@ -9665,8 +11645,8 @@ class ManagedInstanceVersionCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -9690,6 +11670,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ManagedInstanceVersionCapability, self).__init__(**kwargs) self.name = None self.supported_editions = None @@ -9709,21 +11693,22 @@ class ManagedInstanceVulnerabilityAssessment(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param storage_container_path: A blob storage container path to hold the scan results (e.g. + :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). - :type storage_container_path: str - :param storage_container_sas_key: A shared access signature (SAS Key) that has write access to + :vartype storage_container_path: str + :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or a firewall. - :type storage_container_sas_key: str - :param storage_account_access_key: Specifies the identifier key of the storage account for + :vartype storage_container_sas_key: str + :ivar storage_account_access_key: Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet or a firewall. - :type storage_account_access_key: str - :param recurring_scans: The recurring scans settings. - :type recurring_scans: ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + :vartype storage_account_access_key: str + :ivar recurring_scans: The recurring scans settings. + :vartype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties """ _validation = { @@ -9751,6 +11736,24 @@ def __init__( recurring_scans: Optional["VulnerabilityAssessmentRecurringScansProperties"] = None, **kwargs ): + """ + :keyword storage_container_path: A blob storage container path to hold the scan results (e.g. + https://myStorage.blob.core.windows.net/VaScans/). + :paramtype storage_container_path: str + :keyword storage_container_sas_key: A shared access signature (SAS Key) that has write access + to the blob container specified in 'storageContainerPath' parameter. If + 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if + the storage account is not behind a Vnet or a firewall. + :paramtype storage_container_sas_key: str + :keyword storage_account_access_key: Specifies the identifier key of the storage account for + vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, + storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet + or a firewall. + :paramtype storage_account_access_key: str + :keyword recurring_scans: The recurring scans settings. + :paramtype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + """ super(ManagedInstanceVulnerabilityAssessment, self).__init__(**kwargs) self.storage_container_path = storage_container_path self.storage_container_sas_key = storage_container_sas_key @@ -9783,6 +11786,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedInstanceVulnerabilityAssessmentListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -9801,27 +11806,27 @@ class ManagedServerSecurityAlertPolicy(ProxyResource): :vartype type: str :ivar system_data: SystemData of SecurityAlertPolicyResource. :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy + :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState + :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype disabled_alerts: list[str] + :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :vartype email_addresses: list[str] + :ivar email_account_admins: Specifies that the alert is sent to the account administrators. + :vartype email_account_admins: bool + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int + :vartype storage_account_access_key: str + :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. + :vartype retention_days: int :ivar creation_time: Specifies the UTC creation time of the policy. :vartype creation_time: ~datetime.datetime """ @@ -9861,6 +11866,30 @@ def __init__( retention_days: Optional[int] = None, **kwargs ): + """ + :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a + policy has not been applied yet on the specific database. Possible values include: "Enabled", + "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState + :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, + Brute_Force. + :paramtype disabled_alerts: list[str] + :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :paramtype email_addresses: list[str] + :keyword email_account_admins: Specifies that the alert is sent to the account administrators. + :paramtype email_account_admins: bool + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection + audit logs. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit + storage account. + :paramtype storage_account_access_key: str + :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit + logs. + :paramtype retention_days: int + """ super(ManagedServerSecurityAlertPolicy, self).__init__(**kwargs) self.system_data = None self.state = state @@ -9898,6 +11927,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedServerSecurityAlertPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -9914,9 +11945,9 @@ class ManagedTransparentDataEncryption(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param state: Specifies the state of the transparent data encryption. Possible values include: + :ivar state: Specifies the state of the transparent data encryption. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + :vartype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState """ _validation = { @@ -9938,6 +11969,11 @@ def __init__( state: Optional[Union[str, "TransparentDataEncryptionState"]] = None, **kwargs ): + """ + :keyword state: Specifies the state of the transparent data encryption. Possible values + include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + """ super(ManagedTransparentDataEncryption, self).__init__(**kwargs) self.state = state @@ -9967,6 +12003,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedTransparentDataEncryptionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -9998,6 +12036,8 @@ def __init__( self, **kwargs ): + """ + """ super(MaxSizeCapability, self).__init__(**kwargs) self.limit = None self.unit = None @@ -10020,8 +12060,8 @@ class MaxSizeRangeCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -10047,6 +12087,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(MaxSizeRangeCapability, self).__init__(**kwargs) self.min_value = None self.max_value = None @@ -10098,6 +12142,8 @@ def __init__( self, **kwargs ): + """ + """ super(Metric, self).__init__(**kwargs) self.start_time = None self.end_time = None @@ -10132,6 +12178,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricAvailability, self).__init__(**kwargs) self.retention = None self.time_grain = None @@ -10176,6 +12224,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricDefinition, self).__init__(**kwargs) self.name = None self.primary_aggregation_type = None @@ -10189,8 +12239,8 @@ class MetricDefinitionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of metric definitions for the database. - :type value: list[~azure.mgmt.sql.models.MetricDefinition] + :ivar value: Required. The list of metric definitions for the database. + :vartype value: list[~azure.mgmt.sql.models.MetricDefinition] """ _validation = { @@ -10207,6 +12257,10 @@ def __init__( value: List["MetricDefinition"], **kwargs ): + """ + :keyword value: Required. The list of metric definitions for the database. + :paramtype value: list[~azure.mgmt.sql.models.MetricDefinition] + """ super(MetricDefinitionListResult, self).__init__(**kwargs) self.value = value @@ -10216,8 +12270,8 @@ class MetricListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of metrics for the database. - :type value: list[~azure.mgmt.sql.models.Metric] + :ivar value: Required. The list of metrics for the database. + :vartype value: list[~azure.mgmt.sql.models.Metric] """ _validation = { @@ -10234,6 +12288,10 @@ def __init__( value: List["Metric"], **kwargs ): + """ + :keyword value: Required. The list of metrics for the database. + :paramtype value: list[~azure.mgmt.sql.models.Metric] + """ super(MetricListResult, self).__init__(**kwargs) self.value = value @@ -10263,6 +12321,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricName, self).__init__(**kwargs) self.value = None self.localized_value = None @@ -10309,6 +12369,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricValue, self).__init__(**kwargs) self.count = None self.average = None @@ -10328,8 +12390,8 @@ class MinCapacityCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -10349,6 +12411,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(MinCapacityCapability, self).__init__(**kwargs) self.value = None self.status = None @@ -10358,10 +12424,10 @@ def __init__( class Name(msrest.serialization.Model): """ARM Usage Name. - :param value: Usage name value. - :type value: str - :param localized_value: Usage name localized value. - :type localized_value: str + :ivar value: Usage name value. + :vartype value: str + :ivar localized_value: Usage name localized value. + :vartype localized_value: str """ _attribute_map = { @@ -10376,6 +12442,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Usage name value. + :paramtype value: str + :keyword localized_value: Usage name localized value. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -10384,14 +12456,14 @@ def __init__( class NetworkIsolationSettings(msrest.serialization.Model): """Contains the ARM resources for which to create private endpoint connection. - :param storage_account_resource_id: The resource id for the storage account used to store - BACPAC file. If set, private endpoint connection will be created for the storage account. Must - match storage account used for StorageUri parameter. - :type storage_account_resource_id: str - :param sql_server_resource_id: The resource id for the SQL server which is the target of this + :ivar storage_account_resource_id: The resource id for the storage account used to store BACPAC + file. If set, private endpoint connection will be created for the storage account. Must match + storage account used for StorageUri parameter. + :vartype storage_account_resource_id: str + :ivar sql_server_resource_id: The resource id for the SQL server which is the target of this request. If set, private endpoint connection will be created for the SQL server. Must match server which is target of the operation. - :type sql_server_resource_id: str + :vartype sql_server_resource_id: str """ _attribute_map = { @@ -10406,6 +12478,16 @@ def __init__( sql_server_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_resource_id: The resource id for the storage account used to store + BACPAC file. If set, private endpoint connection will be created for the storage account. Must + match storage account used for StorageUri parameter. + :paramtype storage_account_resource_id: str + :keyword sql_server_resource_id: The resource id for the SQL server which is the target of this + request. If set, private endpoint connection will be created for the SQL server. Must match + server which is target of the operation. + :paramtype sql_server_resource_id: str + """ super(NetworkIsolationSettings, self).__init__(**kwargs) self.storage_account_resource_id = storage_account_resource_id self.sql_server_resource_id = sql_server_resource_id @@ -10445,6 +12527,8 @@ def __init__( self, **kwargs ): + """ + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = None @@ -10486,6 +12570,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -10526,6 +12612,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationImpact, self).__init__(**kwargs) self.name = None self.unit = None @@ -10558,88 +12646,13 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None -class OperationsHealth(ProxyResource): - """Operations health status in a location. - - 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 name_properties_name: Operation name for the service. - :vartype name_properties_name: str - :ivar health: Operation health status of the service. - :vartype health: str - :ivar description: Health status description. - :vartype description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'name_properties_name': {'readonly': True}, - 'health': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'health': {'key': 'properties.health', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsHealth, self).__init__(**kwargs) - self.name_properties_name = None - self.health = None - self.description = None - - -class OperationsHealthListResult(msrest.serialization.Model): - """A list of service health statuses in a location. - - 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.OperationsHealth] - :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': '[OperationsHealth]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsHealthListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - class OutboundFirewallRule(ProxyResource): """An Azure SQL DB Server Outbound Firewall Rule. @@ -10673,6 +12686,8 @@ def __init__( self, **kwargs ): + """ + """ super(OutboundFirewallRule, self).__init__(**kwargs) self.provisioning_state = None @@ -10702,6 +12717,8 @@ def __init__( self, **kwargs ): + """ + """ super(OutboundFirewallRuleListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -10714,8 +12731,8 @@ class PartnerInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Resource identifier of the partner server. - :type id: str + :ivar id: Required. Resource identifier of the partner server. + :vartype id: str :ivar location: Geo location of the partner server. :vartype location: str :ivar replication_role: Replication role of the partner server. Possible values include: @@ -10741,6 +12758,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Resource identifier of the partner server. + :paramtype id: str + """ super(PartnerInfo, self).__init__(**kwargs) self.id = id self.location = None @@ -10752,8 +12773,8 @@ class PartnerRegionInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param location: Geo location of the partner managed instances. - :type location: str + :ivar location: Geo location of the partner managed instances. + :vartype location: str :ivar replication_role: Replication role of the partner managed instances. Possible values include: "Primary", "Secondary". :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole @@ -10774,6 +12795,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: Geo location of the partner managed instances. + :paramtype location: str + """ super(PartnerRegionInfo, self).__init__(**kwargs) self.location = location self.replication_role = None @@ -10805,6 +12830,8 @@ def __init__( self, **kwargs ): + """ + """ super(PerformanceLevelCapability, self).__init__(**kwargs) self.value = None self.unit = None @@ -10821,11 +12848,11 @@ class PrivateEndpointConnection(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty - :param private_link_service_connection_state: Connection state of the private endpoint + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty + :ivar private_link_service_connection_state: Connection state of the private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the private endpoint connection. Possible values include: "Approving", "Ready", "Dropping", "Failed", "Rejecting". @@ -10855,6 +12882,14 @@ def __init__( private_link_service_connection_state: Optional["PrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty + :keyword private_link_service_connection_state: Connection state of the private endpoint + connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -10886,6 +12921,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -10896,11 +12933,11 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty - :param private_link_service_connection_state: Connection state of the private endpoint + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty + :ivar private_link_service_connection_state: Connection state of the private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the private endpoint connection. Possible values include: "Approving", "Ready", "Dropping", "Failed", "Rejecting". @@ -10924,6 +12961,14 @@ def __init__( private_link_service_connection_state: Optional["PrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty + :keyword private_link_service_connection_state: Connection state of the private endpoint + connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -10959,6 +13004,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpointConnectionRequestStatus, self).__init__(**kwargs) self.private_link_service_id = None self.private_endpoint_connection_name = None @@ -10968,8 +13015,8 @@ def __init__( class PrivateEndpointProperty(msrest.serialization.Model): """PrivateEndpointProperty. - :param id: Resource id of the private endpoint. - :type id: str + :ivar id: Resource id of the private endpoint. + :vartype id: str """ _attribute_map = { @@ -10982,6 +13029,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource id of the private endpoint. + :paramtype id: str + """ super(PrivateEndpointProperty, self).__init__(**kwargs) self.id = id @@ -11019,6 +13070,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResource, self).__init__(**kwargs) self.properties = None @@ -11048,6 +13101,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -11082,6 +13137,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResourceProperties, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -11095,11 +13152,11 @@ class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. The private link service connection status. Possible values include: + :ivar status: Required. The private link service connection status. Possible values include: "Approved", "Pending", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus - :param description: Required. The private link service connection description. - :type description: str + :vartype status: str or ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus + :ivar description: Required. The private link service connection description. + :vartype description: str :ivar actions_required: The actions required for private link service connection. Possible values include: "None". :vartype actions_required: str or @@ -11125,6 +13182,13 @@ def __init__( description: str, **kwargs ): + """ + :keyword status: Required. The private link service connection status. Possible values include: + "Approved", "Pending", "Rejected", "Disconnected". + :paramtype status: str or ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus + :keyword description: Required. The private link service connection description. + :paramtype description: str + """ super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) self.status = status self.description = description @@ -11142,8 +13206,8 @@ class QueryMetricInterval(msrest.serialization.Model): :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType :ivar execution_count: Execution count of a query in this interval. :vartype execution_count: long - :param metrics: List of metric objects for this interval. - :type metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] + :ivar metrics: List of metric objects for this interval. + :vartype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] """ _validation = { @@ -11165,6 +13229,10 @@ def __init__( metrics: Optional[List["QueryMetricProperties"]] = None, **kwargs ): + """ + :keyword metrics: List of metric objects for this interval. + :paramtype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] + """ super(QueryMetricInterval, self).__init__(**kwargs) self.interval_start_time = None self.interval_type = None @@ -11226,6 +13294,8 @@ def __init__( self, **kwargs ): + """ + """ super(QueryMetricProperties, self).__init__(**kwargs) self.name = None self.display_name = None @@ -11257,8 +13327,8 @@ class QueryStatistics(ProxyResource): :vartype start_time: str :ivar end_time: The end time for the metric (ISO-8601 format). :vartype end_time: str - :param intervals: List of intervals with appropriate metric data. - :type intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] + :ivar intervals: List of intervals with appropriate metric data. + :vartype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] """ _validation = { @@ -11288,6 +13358,10 @@ def __init__( intervals: Optional[List["QueryMetricInterval"]] = None, **kwargs ): + """ + :keyword intervals: List of intervals with appropriate metric data. + :paramtype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] + """ super(QueryStatistics, self).__init__(**kwargs) self.database_name = None self.query_id = None @@ -11309,8 +13383,8 @@ class QueryStatisticsProperties(msrest.serialization.Model): :vartype start_time: str :ivar end_time: The end time for the metric (ISO-8601 format). :vartype end_time: str - :param intervals: List of intervals with appropriate metric data. - :type intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] + :ivar intervals: List of intervals with appropriate metric data. + :vartype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] """ _validation = { @@ -11334,6 +13408,10 @@ def __init__( intervals: Optional[List["QueryMetricInterval"]] = None, **kwargs ): + """ + :keyword intervals: List of intervals with appropriate metric data. + :paramtype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] + """ super(QueryStatisticsProperties, self).__init__(**kwargs) self.database_name = None self.query_id = None @@ -11352,8 +13430,8 @@ class ReadScaleCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -11373,6 +13451,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ReadScaleCapability, self).__init__(**kwargs) self.max_number_of_replicas = None self.status = None @@ -11401,8 +13483,8 @@ class RecommendedAction(ProxyResource): :vartype valid_since: ~datetime.datetime :ivar last_refresh: Gets time when this recommended action was last refreshed. :vartype last_refresh: ~datetime.datetime - :param state: Gets the info of the current state the recommended action is in. - :type state: ~azure.mgmt.sql.models.RecommendedActionStateInfo + :ivar state: Gets the info of the current state the recommended action is in. + :vartype state: ~azure.mgmt.sql.models.RecommendedActionStateInfo :ivar is_executable_action: Gets if this recommended action is actionable by user. :vartype is_executable_action: bool :ivar is_revertable_action: Gets if changes applied by this recommended action can be reverted @@ -11527,6 +13609,10 @@ def __init__( state: Optional["RecommendedActionStateInfo"] = None, **kwargs ): + """ + :keyword state: Gets the info of the current state the recommended action is in. + :paramtype state: ~azure.mgmt.sql.models.RecommendedActionStateInfo + """ super(RecommendedAction, self).__init__(**kwargs) self.kind = None self.location = None @@ -11582,6 +13668,8 @@ def __init__( self, **kwargs ): + """ + """ super(RecommendedActionErrorInfo, self).__init__(**kwargs) self.error_code = None self.is_retryable = None @@ -11629,6 +13717,8 @@ def __init__( self, **kwargs ): + """ + """ super(RecommendedActionImpactRecord, self).__init__(**kwargs) self.dimension_name = None self.unit = None @@ -11664,6 +13754,8 @@ def __init__( self, **kwargs ): + """ + """ super(RecommendedActionImplementationInfo, self).__init__(**kwargs) self.method = None self.script = None @@ -11707,6 +13799,8 @@ def __init__( self, **kwargs ): + """ + """ super(RecommendedActionMetricInfo, self).__init__(**kwargs) self.metric_name = None self.unit = None @@ -11722,7 +13816,7 @@ class RecommendedActionStateInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param current_value: Required. Current state the recommended action is in. Some commonly used + :ivar current_value: Required. Current state the recommended action is in. Some commonly used states are: Active -> recommended action is active and no action has been taken yet. Pending -> recommended action is approved for and is awaiting execution. Executing -> recommended action is being applied on the user database. Verifying -> recommended action was @@ -11735,7 +13829,7 @@ class RecommendedActionStateInfo(msrest.serialization.Model): Possible values include: "Active", "Pending", "Executing", "Verifying", "PendingRevert", "RevertCancelled", "Reverting", "Reverted", "Ignored", "Expired", "Monitoring", "Resolved", "Success", "Error". - :type current_value: str or ~azure.mgmt.sql.models.RecommendedActionCurrentState + :vartype current_value: str or ~azure.mgmt.sql.models.RecommendedActionCurrentState :ivar action_initiated_by: Gets who initiated the execution of this recommended action. Possible Value are: User -> When user explicity notified system to apply the recommended action. System -> When auto-execute status of this advisor was set to 'Enabled', in which case @@ -11763,6 +13857,22 @@ def __init__( current_value: Union[str, "RecommendedActionCurrentState"], **kwargs ): + """ + :keyword current_value: Required. Current state the recommended action is in. Some commonly + used states are: Active -> recommended action is active and no action has been taken yet. + Pending -> recommended action is approved for and is awaiting execution. Executing -> + recommended action is being applied on the user database. Verifying -> recommended action was + applied and is being verified of its usefulness by the system. Success -> recommended + action was applied and improvement found during verification. Pending Revert -> verification + found little or no improvement so recommended action is queued for revert or user has manually + reverted. Reverting -> changes made while applying recommended action are being reverted on + the user database. Reverted -> successfully reverted the changes made by recommended action + on user database. Ignored -> user explicitly ignored/discarded the recommended action. + Possible values include: "Active", "Pending", "Executing", "Verifying", "PendingRevert", + "RevertCancelled", "Reverting", "Reverted", "Ignored", "Expired", "Monitoring", "Resolved", + "Success", "Error". + :paramtype current_value: str or ~azure.mgmt.sql.models.RecommendedActionCurrentState + """ super(RecommendedActionStateInfo, self).__init__(**kwargs) self.current_value = current_value self.action_initiated_by = None @@ -11780,14 +13890,14 @@ class RecommendedSensitivityLabelUpdate(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param op: Possible values include: "enable", "disable". - :type op: str or ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind - :param schema: Schema name of the column to update. - :type schema: str - :param table: Table name of the column to update. - :type table: str - :param column: Column name to update. - :type column: str + :ivar op: Possible values include: "enable", "disable". + :vartype op: str or ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind + :ivar schema: Schema name of the column to update. + :vartype schema: str + :ivar table: Table name of the column to update. + :vartype table: str + :ivar column: Column name to update. + :vartype column: str """ _validation = { @@ -11815,6 +13925,16 @@ def __init__( column: Optional[str] = None, **kwargs ): + """ + :keyword op: Possible values include: "enable", "disable". + :paramtype op: str or ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind + :keyword schema: Schema name of the column to update. + :paramtype schema: str + :keyword table: Table name of the column to update. + :paramtype table: str + :keyword column: Column name to update. + :paramtype column: str + """ super(RecommendedSensitivityLabelUpdate, self).__init__(**kwargs) self.op = op self.schema = schema @@ -11825,8 +13945,8 @@ def __init__( class RecommendedSensitivityLabelUpdateList(msrest.serialization.Model): """A list of recommended sensitivity label update operations. - :param operations: - :type operations: list[~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate] + :ivar operations: + :vartype operations: list[~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate] """ _attribute_map = { @@ -11839,6 +13959,10 @@ def __init__( operations: Optional[List["RecommendedSensitivityLabelUpdate"]] = None, **kwargs ): + """ + :keyword operations: + :paramtype operations: list[~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate] + """ super(RecommendedSensitivityLabelUpdateList, self).__init__(**kwargs) self.operations = operations @@ -11889,6 +14013,8 @@ def __init__( self, **kwargs ): + """ + """ super(RecoverableDatabase, self).__init__(**kwargs) self.edition = None self.service_level_objective = None @@ -11901,8 +14027,8 @@ class RecoverableDatabaseListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. A list of recoverable databases. - :type value: list[~azure.mgmt.sql.models.RecoverableDatabase] + :ivar value: Required. A list of recoverable databases. + :vartype value: list[~azure.mgmt.sql.models.RecoverableDatabase] """ _validation = { @@ -11919,6 +14045,10 @@ def __init__( value: List["RecoverableDatabase"], **kwargs ): + """ + :keyword value: Required. A list of recoverable databases. + :paramtype value: list[~azure.mgmt.sql.models.RecoverableDatabase] + """ super(RecoverableDatabaseListResult, self).__init__(**kwargs) self.value = value @@ -11956,6 +14086,8 @@ def __init__( self, **kwargs ): + """ + """ super(RecoverableManagedDatabase, self).__init__(**kwargs) self.last_available_backup_date = None @@ -11985,6 +14117,8 @@ def __init__( self, **kwargs ): + """ + """ super(RecoverableManagedDatabaseListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12066,6 +14200,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReplicationLink, self).__init__(**kwargs) self.partner_server = None self.partner_database = None @@ -12105,6 +14241,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReplicationLinkListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12115,14 +14253,14 @@ class ResourceIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param user_assigned_identities: The resource ids of the user assigned identities to use. - :type user_assigned_identities: dict[str, ~azure.mgmt.sql.models.UserIdentity] + :ivar user_assigned_identities: The resource ids of the user assigned identities to use. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.UserIdentity] :ivar principal_id: The Azure Active Directory principal id. :vartype principal_id: str - :param type: The identity type. Set this to 'SystemAssigned' in order to automatically create + :ivar type: The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". - :type type: str or ~azure.mgmt.sql.models.IdentityType + :vartype type: str or ~azure.mgmt.sql.models.IdentityType :ivar tenant_id: The Azure Active Directory tenant id. :vartype tenant_id: str """ @@ -12146,6 +14284,14 @@ def __init__( type: Optional[Union[str, "IdentityType"]] = None, **kwargs ): + """ + :keyword user_assigned_identities: The resource ids of the user assigned identities to use. + :paramtype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.UserIdentity] + :keyword type: The identity type. Set this to 'SystemAssigned' in order to automatically create + and assign an Azure Active Directory principal for the resource. Possible values include: + "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.sql.models.IdentityType + """ super(ResourceIdentity, self).__init__(**kwargs) self.user_assigned_identities = user_assigned_identities self.principal_id = None @@ -12158,8 +14304,8 @@ class ResourceMoveDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. The target ID for the resource. - :type id: str + :ivar id: Required. The target ID for the resource. + :vartype id: str """ _validation = { @@ -12176,6 +14322,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. The target ID for the resource. + :paramtype id: str + """ super(ResourceMoveDefinition, self).__init__(**kwargs) self.id = id @@ -12191,12 +14341,12 @@ class RestorableDroppedDatabase(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param sku: The name and tier of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar database_name: The name of the database. :vartype database_name: str :ivar max_size_bytes: The max size of the database expressed in bytes. @@ -12247,6 +14397,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword sku: The name and tier of the SKU. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(RestorableDroppedDatabase, self).__init__(**kwargs) self.sku = sku self.location = location @@ -12284,6 +14442,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableDroppedDatabaseListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12302,10 +14462,10 @@ class RestorableDroppedManagedDatabase(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar database_name: The name of the database. :vartype database_name: str :ivar creation_date: The creation date of the database (ISO8601 format). @@ -12346,6 +14506,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(RestorableDroppedManagedDatabase, self).__init__(location=location, tags=tags, **kwargs) self.database_name = None self.creation_date = None @@ -12378,6 +14544,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableDroppedManagedDatabaseListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12433,6 +14601,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorePoint, self).__init__(**kwargs) self.location = None self.restore_point_type = None @@ -12466,6 +14636,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorePointListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12539,6 +14711,8 @@ def __init__( self, **kwargs ): + """ + """ super(SecurityEvent, self).__init__(**kwargs) self.event_time = None self.security_event_type = None @@ -12576,6 +14750,8 @@ def __init__( self, **kwargs ): + """ + """ super(SecurityEventCollection, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12584,10 +14760,10 @@ def __init__( class SecurityEventsFilterParameters(msrest.serialization.Model): """The properties that are supported in the $filter operation. - :param event_time: Filter on the event time. - :type event_time: ~datetime.datetime - :param show_server_records: Whether to show server records or not. - :type show_server_records: bool + :ivar event_time: Filter on the event time. + :vartype event_time: ~datetime.datetime + :ivar show_server_records: Whether to show server records or not. + :vartype show_server_records: bool """ _attribute_map = { @@ -12602,6 +14778,12 @@ def __init__( show_server_records: Optional[bool] = None, **kwargs ): + """ + :keyword event_time: Filter on the event time. + :paramtype event_time: ~datetime.datetime + :keyword show_server_records: Whether to show server records or not. + :paramtype show_server_records: bool + """ super(SecurityEventsFilterParameters, self).__init__(**kwargs) self.event_time = event_time self.show_server_records = show_server_records @@ -12652,6 +14834,8 @@ def __init__( self, **kwargs ): + """ + """ super(SecurityEventSqlInjectionAdditionalProperties, self).__init__(**kwargs) self.threat_id = None self.statement = None @@ -12681,20 +14865,20 @@ class SensitivityLabel(ProxyResource): :vartype table_name: str :ivar column_name: The column name. :vartype column_name: str - :param label_name: The label name. - :type label_name: str - :param label_id: The label ID. - :type label_id: str - :param information_type: The information type. - :type information_type: str - :param information_type_id: The information type ID. - :type information_type_id: str + :ivar label_name: The label name. + :vartype label_name: str + :ivar label_id: The label ID. + :vartype label_id: str + :ivar information_type: The information type. + :vartype information_type: str + :ivar information_type_id: The information type ID. + :vartype information_type_id: str :ivar is_disabled: Is sensitivity recommendation disabled. Applicable for recommended sensitivity label only. Specifies whether the sensitivity recommendation on this column is disabled (dismissed) or not. :vartype is_disabled: bool - :param rank: Possible values include: "None", "Low", "Medium", "High", "Critical". - :type rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank + :ivar rank: Possible values include: "None", "Low", "Medium", "High", "Critical". + :vartype rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank """ _validation = { @@ -12734,6 +14918,18 @@ def __init__( rank: Optional[Union[str, "SensitivityLabelRank"]] = None, **kwargs ): + """ + :keyword label_name: The label name. + :paramtype label_name: str + :keyword label_id: The label ID. + :paramtype label_id: str + :keyword information_type: The information type. + :paramtype information_type: str + :keyword information_type_id: The information type ID. + :paramtype information_type_id: str + :keyword rank: Possible values include: "None", "Low", "Medium", "High", "Critical". + :paramtype rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank + """ super(SensitivityLabel, self).__init__(**kwargs) self.managed_by = None self.schema_name = None @@ -12772,6 +14968,8 @@ def __init__( self, **kwargs ): + """ + """ super(SensitivityLabelListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12788,16 +14986,16 @@ class SensitivityLabelUpdate(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param op: Possible values include: "set", "remove". - :type op: str or ~azure.mgmt.sql.models.SensitivityLabelUpdateKind - :param schema: Schema name of the column to update. - :type schema: str - :param table: Table name of the column to update. - :type table: str - :param column: Column name to update. - :type column: str - :param sensitivity_label: The sensitivity label information to apply on a column. - :type sensitivity_label: ~azure.mgmt.sql.models.SensitivityLabel + :ivar op: Possible values include: "set", "remove". + :vartype op: str or ~azure.mgmt.sql.models.SensitivityLabelUpdateKind + :ivar schema: Schema name of the column to update. + :vartype schema: str + :ivar table: Table name of the column to update. + :vartype table: str + :ivar column: Column name to update. + :vartype column: str + :ivar sensitivity_label: The sensitivity label information to apply on a column. + :vartype sensitivity_label: ~azure.mgmt.sql.models.SensitivityLabel """ _validation = { @@ -12827,6 +15025,18 @@ def __init__( sensitivity_label: Optional["SensitivityLabel"] = None, **kwargs ): + """ + :keyword op: Possible values include: "set", "remove". + :paramtype op: str or ~azure.mgmt.sql.models.SensitivityLabelUpdateKind + :keyword schema: Schema name of the column to update. + :paramtype schema: str + :keyword table: Table name of the column to update. + :paramtype table: str + :keyword column: Column name to update. + :paramtype column: str + :keyword sensitivity_label: The sensitivity label information to apply on a column. + :paramtype sensitivity_label: ~azure.mgmt.sql.models.SensitivityLabel + """ super(SensitivityLabelUpdate, self).__init__(**kwargs) self.op = op self.schema = schema @@ -12838,8 +15048,8 @@ def __init__( class SensitivityLabelUpdateList(msrest.serialization.Model): """A list of sensitivity label update operations. - :param operations: - :type operations: list[~azure.mgmt.sql.models.SensitivityLabelUpdate] + :ivar operations: + :vartype operations: list[~azure.mgmt.sql.models.SensitivityLabelUpdate] """ _attribute_map = { @@ -12852,6 +15062,10 @@ def __init__( operations: Optional[List["SensitivityLabelUpdate"]] = None, **kwargs ): + """ + :keyword operations: + :paramtype operations: list[~azure.mgmt.sql.models.SensitivityLabelUpdate] + """ super(SensitivityLabelUpdateList, self).__init__(**kwargs) self.operations = operations @@ -12869,22 +15083,22 @@ class Server(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: The Azure Active Directory identity of the server. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar identity: The Azure Active Directory identity of the server. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity :ivar kind: Kind of sql server. This is metadata used for the Azure portal experience. :vartype kind: str - :param administrator_login: Administrator username for the server. Once created it cannot be + :ivar administrator_login: Administrator username for the server. Once created it cannot be changed. - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for server + :vartype administrator_login: str + :ivar administrator_login_password: The administrator login password (required for server creation). - :type administrator_login_password: str - :param version: The version of the server. - :type version: str + :vartype administrator_login_password: str + :ivar version: The version of the server. + :vartype version: str :ivar state: The state of the server. :vartype state: str :ivar fully_qualified_domain_name: The fully qualified domain name of the server. @@ -12892,28 +15106,29 @@ class Server(TrackedResource): :ivar private_endpoint_connections: List of private endpoint connections on a server. :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ServerPrivateEndpointConnection] - :param minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. - :type minimal_tls_version: str - :param public_network_access: Whether or not public endpoint access is allowed for this server. + :ivar minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. + :vartype minimal_tls_version: str + :ivar public_network_access: Whether or not public endpoint access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :vartype public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag :ivar workspace_feature: Whether or not existing server has a workspace created and if it allows connection from workspace. Possible values include: "Connected", "Disconnected". :vartype workspace_feature: str or ~azure.mgmt.sql.models.ServerWorkspaceFeature - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param federated_client_id: The Client id used for cross tenant CMK scenario. - :type federated_client_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory identity of the server. - :type administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :param restrict_outbound_network_access: Whether or not to restrict outbound network access for + :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used + by default. + :vartype primary_user_assigned_identity_id: str + :ivar federated_client_id: The Client id used for cross tenant CMK scenario. + :vartype federated_client_id: str + :ivar key_id: A CMK URI of the key to use for encryption. + :vartype key_id: str + :ivar administrators: The Azure Active Directory identity of the server. + :vartype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator + :ivar restrict_outbound_network_access: Whether or not to restrict outbound network access for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: "Enabled", "Disabled". - :type restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :vartype restrict_outbound_network_access: str or + ~azure.mgmt.sql.models.ServerNetworkAccessFlag """ _validation = { @@ -12970,6 +15185,42 @@ def __init__( restrict_outbound_network_access: Optional[Union[str, "ServerNetworkAccessFlag"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: The Azure Active Directory identity of the server. + :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity + :keyword administrator_login: Administrator username for the server. Once created it cannot be + changed. + :paramtype administrator_login: str + :keyword administrator_login_password: The administrator login password (required for server + creation). + :paramtype administrator_login_password: str + :keyword version: The version of the server. + :paramtype version: str + :keyword minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. + :paramtype minimal_tls_version: str + :keyword public_network_access: Whether or not public endpoint access is allowed for this + server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values + include: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be + used by default. + :paramtype primary_user_assigned_identity_id: str + :keyword federated_client_id: The Client id used for cross tenant CMK scenario. + :paramtype federated_client_id: str + :keyword key_id: A CMK URI of the key to use for encryption. + :paramtype key_id: str + :keyword administrators: The Azure Active Directory identity of the server. + :paramtype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator + :keyword restrict_outbound_network_access: Whether or not to restrict outbound network access + for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible + values include: "Enabled", "Disabled". + :paramtype restrict_outbound_network_access: str or + ~azure.mgmt.sql.models.ServerNetworkAccessFlag + """ super(Server, self).__init__(location=location, tags=tags, **kwargs) self.identity = identity self.kind = None @@ -13000,14 +15251,14 @@ class ServerAutomaticTuning(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param desired_state: Automatic tuning desired state. Possible values include: "Custom", - "Auto", "Unspecified". - :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode + :ivar desired_state: Automatic tuning desired state. Possible values include: "Custom", "Auto", + "Unspecified". + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode :ivar actual_state: Automatic tuning actual state. Possible values include: "Custom", "Auto", "Unspecified". :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode - :param options: Automatic tuning options definition. - :type options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningServerOptions] + :ivar options: Automatic tuning options definition. + :vartype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningServerOptions] """ _validation = { @@ -13033,6 +15284,13 @@ def __init__( options: Optional[Dict[str, "AutomaticTuningServerOptions"]] = None, **kwargs ): + """ + :keyword desired_state: Automatic tuning desired state. Possible values include: "Custom", + "Auto", "Unspecified". + :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode + :keyword options: Automatic tuning options definition. + :paramtype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningServerOptions] + """ super(ServerAutomaticTuning, self).__init__(**kwargs) self.desired_state = desired_state self.actual_state = None @@ -13050,15 +15308,15 @@ class ServerAzureADAdministrator(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param administrator_type: Type of the sever administrator. Possible values include: + :ivar administrator_type: Type of the sever administrator. Possible values include: "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :param login: Login name of the server administrator. - :type login: str - :param sid: SID (object ID) of the server administrator. - :type sid: str - :param tenant_id: Tenant ID of the administrator. - :type tenant_id: str + :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :ivar login: Login name of the server administrator. + :vartype login: str + :ivar sid: SID (object ID) of the server administrator. + :vartype sid: str + :ivar tenant_id: Tenant ID of the administrator. + :vartype tenant_id: str :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. :vartype azure_ad_only_authentication: bool """ @@ -13090,6 +15348,17 @@ def __init__( tenant_id: Optional[str] = None, **kwargs ): + """ + :keyword administrator_type: Type of the sever administrator. Possible values include: + "ActiveDirectory". + :paramtype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :keyword login: Login name of the server administrator. + :paramtype login: str + :keyword sid: SID (object ID) of the server administrator. + :paramtype sid: str + :keyword tenant_id: Tenant ID of the administrator. + :paramtype tenant_id: str + """ super(ServerAzureADAdministrator, self).__init__(**kwargs) self.administrator_type = administrator_type self.login = login @@ -13109,8 +15378,8 @@ class ServerAzureADOnlyAuthentication(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :vartype azure_ad_only_authentication: bool """ _validation = { @@ -13132,6 +15401,10 @@ def __init__( azure_ad_only_authentication: Optional[bool] = None, **kwargs ): + """ + :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :paramtype azure_ad_only_authentication: bool + """ super(ServerAzureADOnlyAuthentication, self).__init__(**kwargs) self.azure_ad_only_authentication = azure_ad_only_authentication @@ -13147,8 +15420,8 @@ class ServerBlobAuditingPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, - devops logs will be sent to Azure Monitor. + :ivar is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, devops + logs will be sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true @@ -13162,11 +15435,11 @@ class ServerBlobAuditingPolicy(ProxyResource): For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. - :type is_devops_audit_enabled: bool - :param retention_days: Specifies the number of days to keep in the audit logs in the storage + :vartype is_devops_audit_enabled: bool + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage account. - :type retention_days: int - :param audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and @@ -13234,11 +15507,11 @@ class ServerBlobAuditingPolicy(ProxyResource): For more information, see `Database-Level Audit Actions `_. - :type audit_actions_and_groups: list[str] - :param is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the storage's secondary key. - :type is_storage_secondary_key_in_use: bool - :param is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. @@ -13254,20 +15527,19 @@ class ServerBlobAuditingPolicy(ProxyResource): For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :type queue_delay_ms: int - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + :vartype queue_delay_ms: int + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. @@ -13279,9 +15551,9 @@ class ServerBlobAuditingPolicy(ProxyResource): Contributor' RBAC role to the server identity. For more information, see `Auditing to storage using Managed Identity authentication `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str """ _validation = { @@ -13321,6 +15593,143 @@ def __init__( storage_account_subscription_id: Optional[str] = None, **kwargs ): + """ + :keyword is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, + devops logs will be sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled', + 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should also be created. + + Diagnostic Settings URI format: + PUT + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :paramtype is_devops_audit_enabled: bool + :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :paramtype retention_days: int + :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that :code:`` in the above format can refer to an object like a table, view, or + stored procedure, or an entire database or schema. For the latter cases, the forms + DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :paramtype audit_actions_and_groups: list[str] + :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is + the storage's secondary key. + :paramtype is_storage_secondary_key_in_use: bool + :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :paramtype is_azure_monitor_target_enabled: bool + :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before + audit actions are forced to be processed. + The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + :paramtype queue_delay_ms: int + :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the auditing storage + account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see `Auditing to storage using Managed Identity authentication + `_. + :paramtype storage_account_access_key: str + :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. + :paramtype storage_account_subscription_id: str + """ super(ServerBlobAuditingPolicy, self).__init__(**kwargs) self.is_devops_audit_enabled = is_devops_audit_enabled self.retention_days = retention_days @@ -13359,6 +15768,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerBlobAuditingPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -13381,8 +15792,8 @@ class ServerCommunicationLink(ProxyResource): :vartype kind: str :ivar state: The state. :vartype state: str - :param partner_server: The name of the partner server. - :type partner_server: str + :ivar partner_server: The name of the partner server. + :vartype partner_server: str """ _validation = { @@ -13410,6 +15821,10 @@ def __init__( partner_server: Optional[str] = None, **kwargs ): + """ + :keyword partner_server: The name of the partner server. + :paramtype partner_server: str + """ super(ServerCommunicationLink, self).__init__(**kwargs) self.location = None self.kind = None @@ -13420,8 +15835,8 @@ def __init__( class ServerCommunicationLinkListResult(msrest.serialization.Model): """A list of server communication links. - :param value: The list of server communication links. - :type value: list[~azure.mgmt.sql.models.ServerCommunicationLink] + :ivar value: The list of server communication links. + :vartype value: list[~azure.mgmt.sql.models.ServerCommunicationLink] """ _attribute_map = { @@ -13434,6 +15849,10 @@ def __init__( value: Optional[List["ServerCommunicationLink"]] = None, **kwargs ): + """ + :keyword value: The list of server communication links. + :paramtype value: list[~azure.mgmt.sql.models.ServerCommunicationLink] + """ super(ServerCommunicationLinkListResult, self).__init__(**kwargs) self.value = value @@ -13453,9 +15872,9 @@ class ServerConnectionPolicy(ProxyResource): :vartype location: str :ivar kind: Metadata used for the Azure portal experience. :vartype kind: str - :param connection_type: The server connection type. Possible values include: "Default", + :ivar connection_type: The server connection type. Possible values include: "Default", "Redirect", "Proxy". - :type connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType + :vartype connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType """ _validation = { @@ -13481,6 +15900,11 @@ def __init__( connection_type: Optional[Union[str, "ServerConnectionType"]] = None, **kwargs ): + """ + :keyword connection_type: The server connection type. Possible values include: "Default", + "Redirect", "Proxy". + :paramtype connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType + """ super(ServerConnectionPolicy, self).__init__(**kwargs) self.location = None self.kind = None @@ -13512,6 +15936,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerConnectionPolicyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -13530,7 +15956,7 @@ class ServerDevOpsAuditingSettings(ProxyResource): :vartype type: str :ivar system_data: SystemData of ServerDevOpsAuditSettingsResource. :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param is_azure_monitor_target_enabled: Specifies whether DevOps audit events are sent to Azure + :ivar is_azure_monitor_target_enabled: Specifies whether DevOps audit events are sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. @@ -13545,16 +15971,15 @@ class ServerDevOpsAuditingSettings(ProxyResource): For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. - :type is_azure_monitor_target_enabled: bool - :param state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + :vartype is_azure_monitor_target_enabled: bool + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the auditing storage - account. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. @@ -13566,9 +15991,9 @@ class ServerDevOpsAuditingSettings(ProxyResource): Contributor' RBAC role to the server identity. For more information, see `Auditing to storage using Managed Identity authentication `_. - :type storage_account_access_key: str - :param storage_account_subscription_id: Specifies the blob storage subscription Id. - :type storage_account_subscription_id: str + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str """ _validation = { @@ -13600,6 +16025,47 @@ def __init__( storage_account_subscription_id: Optional[str] = None, **kwargs ): + """ + :keyword is_azure_monitor_target_enabled: Specifies whether DevOps audit events are sent to + Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure DevOps audit, Diagnostic Settings with + 'DevOpsOperationsAudit' diagnostic logs category on the master database should be also created. + + Diagnostic Settings URI format: + PUT + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :paramtype is_azure_monitor_target_enabled: bool + :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the auditing storage + account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see `Auditing to storage using Managed Identity authentication + `_. + :paramtype storage_account_access_key: str + :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. + :paramtype storage_account_subscription_id: str + """ super(ServerDevOpsAuditingSettings, self).__init__(**kwargs) self.system_data = None self.is_azure_monitor_target_enabled = is_azure_monitor_target_enabled @@ -13634,6 +16100,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerDevOpsAuditSettingsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -13672,6 +16140,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerDnsAlias, self).__init__(**kwargs) self.azure_dns_record = None @@ -13681,9 +16151,9 @@ class ServerDnsAliasAcquisition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param old_server_dns_alias_id: Required. The id of the server alias that will be acquired to + :ivar old_server_dns_alias_id: Required. The id of the server alias that will be acquired to point to this server instead. - :type old_server_dns_alias_id: str + :vartype old_server_dns_alias_id: str """ _validation = { @@ -13700,6 +16170,11 @@ def __init__( old_server_dns_alias_id: str, **kwargs ): + """ + :keyword old_server_dns_alias_id: Required. The id of the server alias that will be acquired to + point to this server instead. + :paramtype old_server_dns_alias_id: str + """ super(ServerDnsAliasAcquisition, self).__init__(**kwargs) self.old_server_dns_alias_id = old_server_dns_alias_id @@ -13729,6 +16204,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerDnsAliasListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -13737,20 +16214,20 @@ def __init__( class ServerExternalAdministrator(msrest.serialization.Model): """Properties of a active directory administrator. - :param administrator_type: Type of the sever administrator. Possible values include: + :ivar administrator_type: Type of the sever administrator. Possible values include: "ActiveDirectory". - :type administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :param principal_type: Principal Type of the sever administrator. Possible values include: + :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :ivar principal_type: Principal Type of the sever administrator. Possible values include: "User", "Group", "Application". - :type principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :param login: Login name of the server administrator. - :type login: str - :param sid: SID (object ID) of the server administrator. - :type sid: str - :param tenant_id: Tenant ID of the administrator. - :type tenant_id: str - :param azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :type azure_ad_only_authentication: bool + :vartype principal_type: str or ~azure.mgmt.sql.models.PrincipalType + :ivar login: Login name of the server administrator. + :vartype login: str + :ivar sid: SID (object ID) of the server administrator. + :vartype sid: str + :ivar tenant_id: Tenant ID of the administrator. + :vartype tenant_id: str + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :vartype azure_ad_only_authentication: bool """ _attribute_map = { @@ -13773,6 +16250,22 @@ def __init__( azure_ad_only_authentication: Optional[bool] = None, **kwargs ): + """ + :keyword administrator_type: Type of the sever administrator. Possible values include: + "ActiveDirectory". + :paramtype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :keyword principal_type: Principal Type of the sever administrator. Possible values include: + "User", "Group", "Application". + :paramtype principal_type: str or ~azure.mgmt.sql.models.PrincipalType + :keyword login: Login name of the server administrator. + :paramtype login: str + :keyword sid: SID (object ID) of the server administrator. + :paramtype sid: str + :keyword tenant_id: Tenant ID of the administrator. + :paramtype tenant_id: str + :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :paramtype azure_ad_only_authentication: bool + """ super(ServerExternalAdministrator, self).__init__(**kwargs) self.administrator_type = administrator_type self.principal_type = principal_type @@ -13787,8 +16280,8 @@ class ServerInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param server_id: Required. Server Id. - :type server_id: str + :ivar server_id: Required. Server Id. + :vartype server_id: str """ _validation = { @@ -13805,6 +16298,10 @@ def __init__( server_id: str, **kwargs ): + """ + :keyword server_id: Required. Server Id. + :paramtype server_id: str + """ super(ServerInfo, self).__init__(**kwargs) self.server_id = server_id @@ -13827,12 +16324,12 @@ class ServerKey(ProxyResource): :vartype location: str :ivar subregion: Subregion of the server key. :vartype subregion: str - :param server_key_type: The server key type like 'ServiceManaged', 'AzureKeyVault'. Possible + :ivar server_key_type: The server key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: "ServiceManaged", "AzureKeyVault". - :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :param uri: The URI of the server key. If the ServerKeyType is AzureKeyVault, then the URI is + :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :ivar uri: The URI of the server key. If the ServerKeyType is AzureKeyVault, then the URI is required. - :type uri: str + :vartype uri: str :ivar thumbprint: Thumbprint of the server key. :vartype thumbprint: str :ivar creation_date: The server key creation date. @@ -13874,6 +16371,14 @@ def __init__( uri: Optional[str] = None, **kwargs ): + """ + :keyword server_key_type: The server key type like 'ServiceManaged', 'AzureKeyVault'. Possible + values include: "ServiceManaged", "AzureKeyVault". + :paramtype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :keyword uri: The URI of the server key. If the ServerKeyType is AzureKeyVault, then the URI is + required. + :paramtype uri: str + """ super(ServerKey, self).__init__(**kwargs) self.kind = None self.location = None @@ -13910,6 +16415,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerKeyListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -13940,6 +16447,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -14027,6 +16536,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerOperation, self).__init__(**kwargs) self.operation = None self.operation_friendly_name = None @@ -14068,6 +16579,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerOperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -14098,6 +16611,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerPrivateEndpointConnection, self).__init__(**kwargs) self.id = None self.properties = None @@ -14116,27 +16631,27 @@ class ServerSecurityAlertPolicy(ProxyResource): :vartype type: str :ivar system_data: SystemData of SecurityAlertPolicyResource. :vartype system_data: ~azure.mgmt.sql.models.SystemData - :param state: Specifies the state of the policy, whether it is enabled or disabled or a policy + :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState + :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force. - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. + :vartype disabled_alerts: list[str] + :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :vartype email_addresses: list[str] + :ivar email_account_admins: Specifies that the alert is sent to the account administrators. + :vartype email_account_admins: bool + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the Threat Detection audit + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :type retention_days: int + :vartype storage_account_access_key: str + :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. + :vartype retention_days: int :ivar creation_time: Specifies the UTC creation time of the policy. :vartype creation_time: ~datetime.datetime """ @@ -14176,6 +16691,30 @@ def __init__( retention_days: Optional[int] = None, **kwargs ): + """ + :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a + policy has not been applied yet on the specific database. Possible values include: "Enabled", + "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState + :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, + Brute_Force. + :paramtype disabled_alerts: list[str] + :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :paramtype email_addresses: list[str] + :keyword email_account_admins: Specifies that the alert is sent to the account administrators. + :paramtype email_account_admins: bool + :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. + https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection + audit logs. + :paramtype storage_endpoint: str + :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit + storage account. + :paramtype storage_account_access_key: str + :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit + logs. + :paramtype retention_days: int + """ super(ServerSecurityAlertPolicy, self).__init__(**kwargs) self.system_data = None self.state = state @@ -14199,10 +16738,10 @@ class ServerTrustGroup(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param group_members: Group members information for the server trust group. - :type group_members: list[~azure.mgmt.sql.models.ServerInfo] - :param trust_scopes: Trust scope of the server trust group. - :type trust_scopes: list[str or + :ivar group_members: Group members information for the server trust group. + :vartype group_members: list[~azure.mgmt.sql.models.ServerInfo] + :ivar trust_scopes: Trust scope of the server trust group. + :vartype trust_scopes: list[str or ~azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem] """ @@ -14227,6 +16766,13 @@ def __init__( trust_scopes: Optional[List[Union[str, "ServerTrustGroupPropertiesTrustScopesItem"]]] = None, **kwargs ): + """ + :keyword group_members: Group members information for the server trust group. + :paramtype group_members: list[~azure.mgmt.sql.models.ServerInfo] + :keyword trust_scopes: Trust scope of the server trust group. + :paramtype trust_scopes: list[str or + ~azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem] + """ super(ServerTrustGroup, self).__init__(**kwargs) self.group_members = group_members self.trust_scopes = trust_scopes @@ -14257,6 +16803,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerTrustGroupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -14267,18 +16815,18 @@ class ServerUpdate(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param identity: Server identity. - :type identity: ~azure.mgmt.sql.models.ResourceIdentity - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param administrator_login: Administrator username for the server. Once created it cannot be + :ivar identity: Server identity. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar administrator_login: Administrator username for the server. Once created it cannot be changed. - :type administrator_login: str - :param administrator_login_password: The administrator login password (required for server + :vartype administrator_login: str + :ivar administrator_login_password: The administrator login password (required for server creation). - :type administrator_login_password: str - :param version: The version of the server. - :type version: str + :vartype administrator_login_password: str + :ivar version: The version of the server. + :vartype version: str :ivar state: The state of the server. :vartype state: str :ivar fully_qualified_domain_name: The fully qualified domain name of the server. @@ -14286,28 +16834,29 @@ class ServerUpdate(msrest.serialization.Model): :ivar private_endpoint_connections: List of private endpoint connections on a server. :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ServerPrivateEndpointConnection] - :param minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. - :type minimal_tls_version: str - :param public_network_access: Whether or not public endpoint access is allowed for this server. + :ivar minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. + :vartype minimal_tls_version: str + :ivar public_network_access: Whether or not public endpoint access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :vartype public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag :ivar workspace_feature: Whether or not existing server has a workspace created and if it allows connection from workspace. Possible values include: "Connected", "Disconnected". :vartype workspace_feature: str or ~azure.mgmt.sql.models.ServerWorkspaceFeature - :param primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :type primary_user_assigned_identity_id: str - :param federated_client_id: The Client id used for cross tenant CMK scenario. - :type federated_client_id: str - :param key_id: A CMK URI of the key to use for encryption. - :type key_id: str - :param administrators: The Azure Active Directory identity of the server. - :type administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :param restrict_outbound_network_access: Whether or not to restrict outbound network access for + :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used + by default. + :vartype primary_user_assigned_identity_id: str + :ivar federated_client_id: The Client id used for cross tenant CMK scenario. + :vartype federated_client_id: str + :ivar key_id: A CMK URI of the key to use for encryption. + :vartype key_id: str + :ivar administrators: The Azure Active Directory identity of the server. + :vartype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator + :ivar restrict_outbound_network_access: Whether or not to restrict outbound network access for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: "Enabled", "Disabled". - :type restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :vartype restrict_outbound_network_access: str or + ~azure.mgmt.sql.models.ServerNetworkAccessFlag """ _validation = { @@ -14353,6 +16902,40 @@ def __init__( restrict_outbound_network_access: Optional[Union[str, "ServerNetworkAccessFlag"]] = None, **kwargs ): + """ + :keyword identity: Server identity. + :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword administrator_login: Administrator username for the server. Once created it cannot be + changed. + :paramtype administrator_login: str + :keyword administrator_login_password: The administrator login password (required for server + creation). + :paramtype administrator_login_password: str + :keyword version: The version of the server. + :paramtype version: str + :keyword minimal_tls_version: Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'. + :paramtype minimal_tls_version: str + :keyword public_network_access: Whether or not public endpoint access is allowed for this + server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values + include: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be + used by default. + :paramtype primary_user_assigned_identity_id: str + :keyword federated_client_id: The Client id used for cross tenant CMK scenario. + :paramtype federated_client_id: str + :keyword key_id: A CMK URI of the key to use for encryption. + :paramtype key_id: str + :keyword administrators: The Azure Active Directory identity of the server. + :paramtype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator + :keyword restrict_outbound_network_access: Whether or not to restrict outbound network access + for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible + values include: "Enabled", "Disabled". + :paramtype restrict_outbound_network_access: str or + ~azure.mgmt.sql.models.ServerNetworkAccessFlag + """ super(ServerUpdate, self).__init__(**kwargs) self.identity = identity self.tags = tags @@ -14417,6 +17000,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerUsage, self).__init__(**kwargs) self.name = None self.resource_name = None @@ -14432,8 +17017,8 @@ class ServerUsageListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of server metrics for the server. - :type value: list[~azure.mgmt.sql.models.ServerUsage] + :ivar value: Required. The list of server metrics for the server. + :vartype value: list[~azure.mgmt.sql.models.ServerUsage] """ _validation = { @@ -14450,6 +17035,10 @@ def __init__( value: List["ServerUsage"], **kwargs ): + """ + :keyword value: Required. The list of server metrics for the server. + :paramtype value: list[~azure.mgmt.sql.models.ServerUsage] + """ super(ServerUsageListResult, self).__init__(**kwargs) self.value = value @@ -14469,8 +17058,8 @@ class ServerVersionCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -14494,6 +17083,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ServerVersionCapability, self).__init__(**kwargs) self.name = None self.supported_editions = None @@ -14513,21 +17106,22 @@ class ServerVulnerabilityAssessment(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param storage_container_path: A blob storage container path to hold the scan results (e.g. + :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). - :type storage_container_path: str - :param storage_container_sas_key: A shared access signature (SAS Key) that has write access to + :vartype storage_container_path: str + :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or a firewall. - :type storage_container_sas_key: str - :param storage_account_access_key: Specifies the identifier key of the storage account for + :vartype storage_container_sas_key: str + :ivar storage_account_access_key: Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet or a firewall. - :type storage_account_access_key: str - :param recurring_scans: The recurring scans settings. - :type recurring_scans: ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + :vartype storage_account_access_key: str + :ivar recurring_scans: The recurring scans settings. + :vartype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties """ _validation = { @@ -14555,6 +17149,24 @@ def __init__( recurring_scans: Optional["VulnerabilityAssessmentRecurringScansProperties"] = None, **kwargs ): + """ + :keyword storage_container_path: A blob storage container path to hold the scan results (e.g. + https://myStorage.blob.core.windows.net/VaScans/). + :paramtype storage_container_path: str + :keyword storage_container_sas_key: A shared access signature (SAS Key) that has write access + to the blob container specified in 'storageContainerPath' parameter. If + 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if + the storage account is not behind a Vnet or a firewall. + :paramtype storage_container_sas_key: str + :keyword storage_account_access_key: Specifies the identifier key of the storage account for + vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, + storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet + or a firewall. + :paramtype storage_account_access_key: str + :keyword recurring_scans: The recurring scans settings. + :paramtype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + """ super(ServerVulnerabilityAssessment, self).__init__(**kwargs) self.storage_container_path = storage_container_path self.storage_container_sas_key = storage_container_sas_key @@ -14587,6 +17199,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerVulnerabilityAssessmentListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -14641,6 +17255,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServiceObjective, self).__init__(**kwargs) self.service_objective_name = None self.is_default = None @@ -14682,8 +17298,8 @@ class ServiceObjectiveCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -14725,6 +17341,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(ServiceObjectiveCapability, self).__init__(**kwargs) self.id = None self.name = None @@ -14747,8 +17367,8 @@ class ServiceObjectiveListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of database service objectives. - :type value: list[~azure.mgmt.sql.models.ServiceObjective] + :ivar value: Required. The list of database service objectives. + :vartype value: list[~azure.mgmt.sql.models.ServiceObjective] """ _validation = { @@ -14765,6 +17385,10 @@ def __init__( value: List["ServiceObjective"], **kwargs ): + """ + :keyword value: Required. The list of database service objectives. + :paramtype value: list[~azure.mgmt.sql.models.ServiceObjective] + """ super(ServiceObjectiveListResult, self).__init__(**kwargs) self.value = value @@ -14780,8 +17404,8 @@ class ServicePrincipal(msrest.serialization.Model): :vartype client_id: str :ivar tenant_id: The Azure Active Directory tenant id. :vartype tenant_id: str - :param type: Service principal type. Possible values include: "None", "SystemAssigned". - :type type: str or ~azure.mgmt.sql.models.ServicePrincipalType + :ivar type: Service principal type. Possible values include: "None", "SystemAssigned". + :vartype type: str or ~azure.mgmt.sql.models.ServicePrincipalType """ _validation = { @@ -14803,6 +17427,10 @@ def __init__( type: Optional[Union[str, "ServicePrincipalType"]] = None, **kwargs ): + """ + :keyword type: Service principal type. Possible values include: "None", "SystemAssigned". + :paramtype type: str or ~azure.mgmt.sql.models.ServicePrincipalType + """ super(ServicePrincipal, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -14815,17 +17443,17 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU, typically, a letter + Number code, e.g. P3. - :type name: str - :param tier: The tier or edition of the particular SKU, e.g. Basic, Premium. - :type tier: str - :param size: Size of the particular SKU. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param capacity: Capacity of the particular SKU. - :type capacity: int + :ivar name: Required. The name of the SKU, typically, a letter + Number code, e.g. P3. + :vartype name: str + :ivar tier: The tier or edition of the particular SKU, e.g. Basic, Premium. + :vartype tier: str + :ivar size: Size of the particular SKU. + :vartype size: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str + :ivar capacity: Capacity of the particular SKU. + :vartype capacity: int """ _validation = { @@ -14850,6 +17478,19 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU, typically, a letter + Number code, e.g. P3. + :paramtype name: str + :keyword tier: The tier or edition of the particular SKU, e.g. Basic, Premium. + :paramtype tier: str + :keyword size: Size of the particular SKU. + :paramtype size: str + :keyword family: If the service has different generations of hardware, for the same SKU, then + that can be captured here. + :paramtype family: str + :keyword capacity: Capacity of the particular SKU. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -14894,6 +17535,8 @@ def __init__( self, **kwargs ): + """ + """ super(SloUsageMetric, self).__init__(**kwargs) self.service_level_objective = None self.service_level_objective_id = None @@ -14911,8 +17554,8 @@ class SqlAgentConfiguration(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param state: The state of Sql Agent. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState + :ivar state: The state of Sql Agent. Possible values include: "Enabled", "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState """ _validation = { @@ -14934,6 +17577,10 @@ def __init__( state: Optional[Union[str, "SqlAgentConfigurationPropertiesState"]] = None, **kwargs ): + """ + :keyword state: The state of Sql Agent. Possible values include: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState + """ super(SqlAgentConfiguration, self).__init__(**kwargs) self.state = state @@ -14950,8 +17597,8 @@ class StorageCapability(msrest.serialization.Model): :ivar status: The status of the capability. Possible values include: "Visible", "Available", "Default", "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :param reason: The reason for the capability not being available. - :type reason: str + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { @@ -14971,6 +17618,10 @@ def __init__( reason: Optional[str] = None, **kwargs ): + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ super(StorageCapability, self).__init__(**kwargs) self.storage_account_type = None self.status = None @@ -15022,6 +17673,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionUsage, self).__init__(**kwargs) self.display_name = None self.current_value = None @@ -15054,6 +17707,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionUsageListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15072,8 +17727,8 @@ class SyncAgent(ProxyResource): :vartype type: str :ivar name_properties_name: Name of the sync agent. :vartype name_properties_name: str - :param sync_database_id: ARM resource id of the sync database in the sync agent. - :type sync_database_id: str + :ivar sync_database_id: ARM resource id of the sync database in the sync agent. + :vartype sync_database_id: str :ivar last_alive_time: Last alive time of the sync agent. :vartype last_alive_time: ~datetime.datetime :ivar state: State of the sync agent. Possible values include: "Online", "Offline", @@ -15118,6 +17773,10 @@ def __init__( sync_database_id: Optional[str] = None, **kwargs ): + """ + :keyword sync_database_id: ARM resource id of the sync database in the sync agent. + :paramtype sync_database_id: str + """ super(SyncAgent, self).__init__(**kwargs) self.name_properties_name = None self.sync_database_id = sync_database_id @@ -15149,6 +17808,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncAgentKeyProperties, self).__init__(**kwargs) self.sync_agent_key = None @@ -15207,6 +17868,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncAgentLinkedDatabase, self).__init__(**kwargs) self.database_type = None self.database_id = None @@ -15241,6 +17904,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncAgentLinkedDatabaseListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15271,6 +17936,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncAgentListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15301,6 +17968,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncDatabaseIdListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15327,6 +17996,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncDatabaseIdProperties, self).__init__(**kwargs) self.id = None @@ -15356,6 +18027,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncFullSchemaProperties, self).__init__(**kwargs) self.tables = None self.last_update_time = None @@ -15386,6 +18059,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncFullSchemaPropertiesListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15428,6 +18103,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncFullSchemaTable, self).__init__(**kwargs) self.columns = None self.error_id = None @@ -15481,6 +18158,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncFullSchemaTableColumn, self).__init__(**kwargs) self.data_size = None self.data_type = None @@ -15502,32 +18181,32 @@ class SyncGroup(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param sku: The name and capacity of the SKU. - :type sku: ~azure.mgmt.sql.models.Sku - :param interval: Sync interval of the sync group. - :type interval: int + :ivar sku: The name and capacity of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar interval: Sync interval of the sync group. + :vartype interval: int :ivar last_sync_time: Last sync time of the sync group. :vartype last_sync_time: ~datetime.datetime - :param conflict_resolution_policy: Conflict resolution policy of the sync group. Possible - values include: "HubWin", "MemberWin". - :type conflict_resolution_policy: str or ~azure.mgmt.sql.models.SyncConflictResolutionPolicy - :param sync_database_id: ARM resource id of the sync database in the sync group. - :type sync_database_id: str - :param hub_database_user_name: User name for the sync group hub database credential. - :type hub_database_user_name: str - :param hub_database_password: Password for the sync group hub database credential. - :type hub_database_password: str + :ivar conflict_resolution_policy: Conflict resolution policy of the sync group. Possible values + include: "HubWin", "MemberWin". + :vartype conflict_resolution_policy: str or ~azure.mgmt.sql.models.SyncConflictResolutionPolicy + :ivar sync_database_id: ARM resource id of the sync database in the sync group. + :vartype sync_database_id: str + :ivar hub_database_user_name: User name for the sync group hub database credential. + :vartype hub_database_user_name: str + :ivar hub_database_password: Password for the sync group hub database credential. + :vartype hub_database_password: str :ivar sync_state: Sync state of the sync group. Possible values include: "NotReady", "Error", "Warning", "Progressing", "Good". :vartype sync_state: str or ~azure.mgmt.sql.models.SyncGroupState - :param schema: Sync schema of the sync group. - :type schema: ~azure.mgmt.sql.models.SyncGroupSchema - :param enable_conflict_logging: If conflict logging is enabled. - :type enable_conflict_logging: bool - :param conflict_logging_retention_in_days: Conflict logging retention period. - :type conflict_logging_retention_in_days: int - :param use_private_link_connection: If use private link connection is enabled. - :type use_private_link_connection: bool + :ivar schema: Sync schema of the sync group. + :vartype schema: ~azure.mgmt.sql.models.SyncGroupSchema + :ivar enable_conflict_logging: If conflict logging is enabled. + :vartype enable_conflict_logging: bool + :ivar conflict_logging_retention_in_days: Conflict logging retention period. + :vartype conflict_logging_retention_in_days: int + :ivar use_private_link_connection: If use private link connection is enabled. + :vartype use_private_link_connection: bool :ivar private_endpoint_name: Private endpoint name of the sync group if use private link connection is enabled. :vartype private_endpoint_name: str @@ -15576,6 +18255,30 @@ def __init__( use_private_link_connection: Optional[bool] = None, **kwargs ): + """ + :keyword sku: The name and capacity of the SKU. + :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword interval: Sync interval of the sync group. + :paramtype interval: int + :keyword conflict_resolution_policy: Conflict resolution policy of the sync group. Possible + values include: "HubWin", "MemberWin". + :paramtype conflict_resolution_policy: str or + ~azure.mgmt.sql.models.SyncConflictResolutionPolicy + :keyword sync_database_id: ARM resource id of the sync database in the sync group. + :paramtype sync_database_id: str + :keyword hub_database_user_name: User name for the sync group hub database credential. + :paramtype hub_database_user_name: str + :keyword hub_database_password: Password for the sync group hub database credential. + :paramtype hub_database_password: str + :keyword schema: Sync schema of the sync group. + :paramtype schema: ~azure.mgmt.sql.models.SyncGroupSchema + :keyword enable_conflict_logging: If conflict logging is enabled. + :paramtype enable_conflict_logging: bool + :keyword conflict_logging_retention_in_days: Conflict logging retention period. + :paramtype conflict_logging_retention_in_days: int + :keyword use_private_link_connection: If use private link connection is enabled. + :paramtype use_private_link_connection: bool + """ super(SyncGroup, self).__init__(**kwargs) self.sku = sku self.interval = interval @@ -15617,6 +18320,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncGroupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15647,6 +18352,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncGroupLogListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15694,6 +18401,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncGroupLogProperties, self).__init__(**kwargs) self.timestamp = None self.type = None @@ -15706,10 +18415,10 @@ def __init__( class SyncGroupSchema(msrest.serialization.Model): """Properties of sync group schema. - :param tables: List of tables in sync group schema. - :type tables: list[~azure.mgmt.sql.models.SyncGroupSchemaTable] - :param master_sync_member_name: Name of master sync member where the schema is from. - :type master_sync_member_name: str + :ivar tables: List of tables in sync group schema. + :vartype tables: list[~azure.mgmt.sql.models.SyncGroupSchemaTable] + :ivar master_sync_member_name: Name of master sync member where the schema is from. + :vartype master_sync_member_name: str """ _attribute_map = { @@ -15724,6 +18433,12 @@ def __init__( master_sync_member_name: Optional[str] = None, **kwargs ): + """ + :keyword tables: List of tables in sync group schema. + :paramtype tables: list[~azure.mgmt.sql.models.SyncGroupSchemaTable] + :keyword master_sync_member_name: Name of master sync member where the schema is from. + :paramtype master_sync_member_name: str + """ super(SyncGroupSchema, self).__init__(**kwargs) self.tables = tables self.master_sync_member_name = master_sync_member_name @@ -15732,10 +18447,10 @@ def __init__( class SyncGroupSchemaTable(msrest.serialization.Model): """Properties of table in sync group schema. - :param columns: List of columns in sync group schema. - :type columns: list[~azure.mgmt.sql.models.SyncGroupSchemaTableColumn] - :param quoted_name: Quoted name of sync group schema table. - :type quoted_name: str + :ivar columns: List of columns in sync group schema. + :vartype columns: list[~azure.mgmt.sql.models.SyncGroupSchemaTableColumn] + :ivar quoted_name: Quoted name of sync group schema table. + :vartype quoted_name: str """ _attribute_map = { @@ -15750,6 +18465,12 @@ def __init__( quoted_name: Optional[str] = None, **kwargs ): + """ + :keyword columns: List of columns in sync group schema. + :paramtype columns: list[~azure.mgmt.sql.models.SyncGroupSchemaTableColumn] + :keyword quoted_name: Quoted name of sync group schema table. + :paramtype quoted_name: str + """ super(SyncGroupSchemaTable, self).__init__(**kwargs) self.columns = columns self.quoted_name = quoted_name @@ -15758,12 +18479,12 @@ def __init__( class SyncGroupSchemaTableColumn(msrest.serialization.Model): """Properties of column in sync group table. - :param quoted_name: Quoted name of sync group table column. - :type quoted_name: str - :param data_size: Data size of the column. - :type data_size: str - :param data_type: Data type of the column. - :type data_type: str + :ivar quoted_name: Quoted name of sync group table column. + :vartype quoted_name: str + :ivar data_size: Data size of the column. + :vartype data_size: str + :ivar data_type: Data type of the column. + :vartype data_type: str """ _attribute_map = { @@ -15780,6 +18501,14 @@ def __init__( data_type: Optional[str] = None, **kwargs ): + """ + :keyword quoted_name: Quoted name of sync group table column. + :paramtype quoted_name: str + :keyword data_size: Data size of the column. + :paramtype data_size: str + :keyword data_type: Data type of the column. + :paramtype data_type: str + """ super(SyncGroupSchemaTableColumn, self).__init__(**kwargs) self.quoted_name = quoted_name self.data_size = data_size @@ -15797,32 +18526,32 @@ class SyncMember(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param database_type: Database type of the sync member. Possible values include: + :ivar database_type: Database type of the sync member. Possible values include: "AzureSqlDatabase", "SqlServerDatabase". - :type database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType - :param sync_agent_id: ARM resource id of the sync agent in the sync member. - :type sync_agent_id: str - :param sql_server_database_id: SQL Server database id of the sync member. - :type sql_server_database_id: str - :param sync_member_azure_database_resource_id: ARM resource id of the sync member logical + :vartype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType + :ivar sync_agent_id: ARM resource id of the sync agent in the sync member. + :vartype sync_agent_id: str + :ivar sql_server_database_id: SQL Server database id of the sync member. + :vartype sql_server_database_id: str + :ivar sync_member_azure_database_resource_id: ARM resource id of the sync member logical database, for sync members in Azure. - :type sync_member_azure_database_resource_id: str - :param use_private_link_connection: Whether to use private link connection. - :type use_private_link_connection: bool + :vartype sync_member_azure_database_resource_id: str + :ivar use_private_link_connection: Whether to use private link connection. + :vartype use_private_link_connection: bool :ivar private_endpoint_name: Private endpoint name of the sync member if use private link connection is enabled, for sync members in Azure. :vartype private_endpoint_name: str - :param server_name: Server name of the member database in the sync member. - :type server_name: str - :param database_name: Database name of the member database in the sync member. - :type database_name: str - :param user_name: User name of the member database in the sync member. - :type user_name: str - :param password: Password of the member database in the sync member. - :type password: str - :param sync_direction: Sync direction of the sync member. Possible values include: + :ivar server_name: Server name of the member database in the sync member. + :vartype server_name: str + :ivar database_name: Database name of the member database in the sync member. + :vartype database_name: str + :ivar user_name: User name of the member database in the sync member. + :vartype user_name: str + :ivar password: Password of the member database in the sync member. + :vartype password: str + :ivar sync_direction: Sync direction of the sync member. Possible values include: "Bidirectional", "OneWayMemberToHub", "OneWayHubToMember". - :type sync_direction: str or ~azure.mgmt.sql.models.SyncDirection + :vartype sync_direction: str or ~azure.mgmt.sql.models.SyncDirection :ivar sync_state: Sync state of the sync member. Possible values include: "SyncInProgress", "SyncSucceeded", "SyncFailed", "DisabledTombstoneCleanup", "DisabledBackupRestore", "SyncSucceededWithWarnings", "SyncCancelling", "SyncCancelled", "UnProvisioned", @@ -15872,6 +18601,31 @@ def __init__( sync_direction: Optional[Union[str, "SyncDirection"]] = None, **kwargs ): + """ + :keyword database_type: Database type of the sync member. Possible values include: + "AzureSqlDatabase", "SqlServerDatabase". + :paramtype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType + :keyword sync_agent_id: ARM resource id of the sync agent in the sync member. + :paramtype sync_agent_id: str + :keyword sql_server_database_id: SQL Server database id of the sync member. + :paramtype sql_server_database_id: str + :keyword sync_member_azure_database_resource_id: ARM resource id of the sync member logical + database, for sync members in Azure. + :paramtype sync_member_azure_database_resource_id: str + :keyword use_private_link_connection: Whether to use private link connection. + :paramtype use_private_link_connection: bool + :keyword server_name: Server name of the member database in the sync member. + :paramtype server_name: str + :keyword database_name: Database name of the member database in the sync member. + :paramtype database_name: str + :keyword user_name: User name of the member database in the sync member. + :paramtype user_name: str + :keyword password: Password of the member database in the sync member. + :paramtype password: str + :keyword sync_direction: Sync direction of the sync member. Possible values include: + "Bidirectional", "OneWayMemberToHub", "OneWayHubToMember". + :paramtype sync_direction: str or ~azure.mgmt.sql.models.SyncDirection + """ super(SyncMember, self).__init__(**kwargs) self.database_type = database_type self.sync_agent_id = sync_agent_id @@ -15912,6 +18666,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncMemberListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -15920,20 +18676,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.sql.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.sql.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -15956,6 +18712,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.sql.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.sql.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -15976,10 +18748,10 @@ class TdeCertificate(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param private_blob: The base64 encoded certificate private blob. - :type private_blob: str - :param cert_password: The certificate password. - :type cert_password: str + :ivar private_blob: The base64 encoded certificate private blob. + :vartype private_blob: str + :ivar cert_password: The certificate password. + :vartype cert_password: str """ _validation = { @@ -16003,6 +18775,12 @@ def __init__( cert_password: Optional[str] = None, **kwargs ): + """ + :keyword private_blob: The base64 encoded certificate private blob. + :paramtype private_blob: str + :keyword cert_password: The certificate password. + :paramtype cert_password: str + """ super(TdeCertificate, self).__init__(**kwargs) self.private_blob = private_blob self.cert_password = cert_password @@ -16045,6 +18823,8 @@ def __init__( self, **kwargs ): + """ + """ super(TimeZone, self).__init__(**kwargs) self.time_zone_id = None self.display_name = None @@ -16075,6 +18855,8 @@ def __init__( self, **kwargs ): + """ + """ super(TimeZoneListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -16097,8 +18879,8 @@ class TopQueries(msrest.serialization.Model): :vartype start_time: str :ivar end_time: The end time for the metric (ISO-8601 format). :vartype end_time: str - :param queries: List of top resource consuming queries with appropriate metric data. - :type queries: list[~azure.mgmt.sql.models.QueryStatisticsProperties] + :ivar queries: List of top resource consuming queries with appropriate metric data. + :vartype queries: list[~azure.mgmt.sql.models.QueryStatisticsProperties] """ _validation = { @@ -16126,6 +18908,10 @@ def __init__( queries: Optional[List["QueryStatisticsProperties"]] = None, **kwargs ): + """ + :keyword queries: List of top resource consuming queries with appropriate metric data. + :paramtype queries: list[~azure.mgmt.sql.models.QueryStatisticsProperties] + """ super(TopQueries, self).__init__(**kwargs) self.number_of_queries = None self.aggregation_function = None @@ -16161,6 +18947,8 @@ def __init__( self, **kwargs ): + """ + """ super(TopQueriesListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -16169,9 +18957,9 @@ def __init__( class UnlinkParameters(msrest.serialization.Model): """Represents the parameters for Unlink Replication Link request. - :param forced_termination: Determines whether link will be terminated in a forced or a friendly + :ivar forced_termination: Determines whether link will be terminated in a forced or a friendly way. - :type forced_termination: bool + :vartype forced_termination: bool """ _attribute_map = { @@ -16184,6 +18972,11 @@ def __init__( forced_termination: Optional[bool] = None, **kwargs ): + """ + :keyword forced_termination: Determines whether link will be terminated in a forced or a + friendly way. + :paramtype forced_termination: bool + """ super(UnlinkParameters, self).__init__(**kwargs) self.forced_termination = forced_termination @@ -16191,9 +18984,9 @@ def __init__( class UpdateLongTermRetentionBackupParameters(msrest.serialization.Model): """Contains the information necessary to perform long term retention backup update operation. - :param requested_backup_storage_redundancy: The storage redundancy type of the copied backup. + :ivar requested_backup_storage_redundancy: The storage redundancy type of the copied backup. Possible values include: "Geo", "Local", "Zone", "GeoZone". - :type requested_backup_storage_redundancy: str or + :vartype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy """ @@ -16207,6 +19000,12 @@ def __init__( requested_backup_storage_redundancy: Optional[Union[str, "BackupStorageRedundancy"]] = None, **kwargs ): + """ + :keyword requested_backup_storage_redundancy: The storage redundancy type of the copied backup. + Possible values include: "Geo", "Local", "Zone", "GeoZone". + :paramtype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + """ super(UpdateLongTermRetentionBackupParameters, self).__init__(**kwargs) self.requested_backup_storage_redundancy = requested_backup_storage_redundancy @@ -16245,6 +19044,8 @@ def __init__( self, **kwargs ): + """ + """ super(UpdateManagedInstanceDnsServersOperation, self).__init__(**kwargs) self.status = None @@ -16252,14 +19053,14 @@ def __init__( class UpsertManagedServerOperationParameters(msrest.serialization.Model): """UpsertManagedServerOperationParameters. - :param family: - :type family: str - :param tier: - :type tier: str - :param v_cores: - :type v_cores: int - :param storage_size_in_gb: - :type storage_size_in_gb: int + :ivar family: + :vartype family: str + :ivar tier: + :vartype tier: str + :ivar v_cores: + :vartype v_cores: int + :ivar storage_size_in_gb: + :vartype storage_size_in_gb: int """ _attribute_map = { @@ -16278,6 +19079,16 @@ def __init__( storage_size_in_gb: Optional[int] = None, **kwargs ): + """ + :keyword family: + :paramtype family: str + :keyword tier: + :paramtype tier: str + :keyword v_cores: + :paramtype v_cores: int + :keyword storage_size_in_gb: + :paramtype storage_size_in_gb: int + """ super(UpsertManagedServerOperationParameters, self).__init__(**kwargs) self.family = family self.tier = tier @@ -16288,13 +19099,13 @@ def __init__( class UpsertManagedServerOperationStep(msrest.serialization.Model): """UpsertManagedServerOperationStep. - :param order: - :type order: int - :param name: - :type name: str - :param status: Possible values include: "NotStarted", "InProgress", "SlowedDown", "Completed", + :ivar order: + :vartype order: int + :ivar name: + :vartype name: str + :ivar status: Possible values include: "NotStarted", "InProgress", "SlowedDown", "Completed", "Failed", "Canceled". - :type status: str or ~azure.mgmt.sql.models.UpsertManagedServerOperationStepStatus + :vartype status: str or ~azure.mgmt.sql.models.UpsertManagedServerOperationStepStatus """ _attribute_map = { @@ -16311,6 +19122,15 @@ def __init__( status: Optional[Union[str, "UpsertManagedServerOperationStepStatus"]] = None, **kwargs ): + """ + :keyword order: + :paramtype order: int + :keyword name: + :paramtype name: str + :keyword status: Possible values include: "NotStarted", "InProgress", "SlowedDown", + "Completed", "Failed", "Canceled". + :paramtype status: str or ~azure.mgmt.sql.models.UpsertManagedServerOperationStepStatus + """ super(UpsertManagedServerOperationStep, self).__init__(**kwargs) self.order = order self.name = name @@ -16362,6 +19182,8 @@ def __init__( self, **kwargs ): + """ + """ super(Usage, self).__init__(**kwargs) self.id = None self.name = None @@ -16397,6 +19219,8 @@ def __init__( self, **kwargs ): + """ + """ super(UsageListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -16427,6 +19251,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -16445,20 +19271,20 @@ class VirtualCluster(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar subnet_id: Subnet resource ID for the virtual cluster. :vartype subnet_id: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str :ivar child_resources: List of resources in this virtual cluster. :vartype child_resources: list[str] - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this virtual cluster. - :type maintenance_configuration_id: str + :vartype maintenance_configuration_id: str """ _validation = { @@ -16491,6 +19317,18 @@ def __init__( maintenance_configuration_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword family: If the service has different generations of hardware, for the same SKU, then + that can be captured here. + :paramtype family: str + :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this + virtual cluster. + :paramtype maintenance_configuration_id: str + """ super(VirtualCluster, self).__init__(location=location, tags=tags, **kwargs) self.subnet_id = None self.family = family @@ -16523,6 +19361,8 @@ def __init__( self, **kwargs ): + """ + """ super(VirtualClusterListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -16533,18 +19373,18 @@ class VirtualClusterUpdate(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar subnet_id: Subnet resource ID for the virtual cluster. :vartype subnet_id: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str :ivar child_resources: List of resources in this virtual cluster. :vartype child_resources: list[str] - :param maintenance_configuration_id: Specifies maintenance configuration id to apply to this + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this virtual cluster. - :type maintenance_configuration_id: str + :vartype maintenance_configuration_id: str """ _validation = { @@ -16568,6 +19408,16 @@ def __init__( maintenance_configuration_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword family: If the service has different generations of hardware, for the same SKU, then + that can be captured here. + :paramtype family: str + :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this + virtual cluster. + :paramtype maintenance_configuration_id: str + """ super(VirtualClusterUpdate, self).__init__(**kwargs) self.tags = tags self.subnet_id = None @@ -16587,11 +19437,11 @@ class VirtualNetworkRule(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param virtual_network_subnet_id: The ARM resource id of the virtual network subnet. - :type virtual_network_subnet_id: str - :param ignore_missing_vnet_service_endpoint: Create firewall rule before the virtual network - has vnet service endpoint enabled. - :type ignore_missing_vnet_service_endpoint: bool + :ivar virtual_network_subnet_id: The ARM resource id of the virtual network subnet. + :vartype virtual_network_subnet_id: str + :ivar ignore_missing_vnet_service_endpoint: Create firewall rule before the virtual network has + vnet service endpoint enabled. + :vartype ignore_missing_vnet_service_endpoint: bool :ivar state: Virtual Network Rule State. Possible values include: "Initializing", "InProgress", "Ready", "Failed", "Deleting", "Unknown". :vartype state: str or ~azure.mgmt.sql.models.VirtualNetworkRuleState @@ -16620,6 +19470,13 @@ def __init__( ignore_missing_vnet_service_endpoint: Optional[bool] = None, **kwargs ): + """ + :keyword virtual_network_subnet_id: The ARM resource id of the virtual network subnet. + :paramtype virtual_network_subnet_id: str + :keyword ignore_missing_vnet_service_endpoint: Create firewall rule before the virtual network + has vnet service endpoint enabled. + :paramtype ignore_missing_vnet_service_endpoint: bool + """ super(VirtualNetworkRule, self).__init__(**kwargs) self.virtual_network_subnet_id = virtual_network_subnet_id self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint @@ -16651,6 +19508,8 @@ def __init__( self, **kwargs ): + """ + """ super(VirtualNetworkRuleListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -16659,13 +19518,13 @@ def __init__( class VulnerabilityAssessmentRecurringScansProperties(msrest.serialization.Model): """Properties of a Vulnerability Assessment recurring scans. - :param is_enabled: Recurring scans state. - :type is_enabled: bool - :param email_subscription_admins: Specifies that the schedule scan notification will be is sent + :ivar is_enabled: Recurring scans state. + :vartype is_enabled: bool + :ivar email_subscription_admins: Specifies that the schedule scan notification will be is sent to the subscription administrators. - :type email_subscription_admins: bool - :param emails: Specifies an array of e-mail addresses to which the scan notification is sent. - :type emails: list[str] + :vartype email_subscription_admins: bool + :ivar emails: Specifies an array of e-mail addresses to which the scan notification is sent. + :vartype emails: list[str] """ _attribute_map = { @@ -16682,6 +19541,15 @@ def __init__( emails: Optional[List[str]] = None, **kwargs ): + """ + :keyword is_enabled: Recurring scans state. + :paramtype is_enabled: bool + :keyword email_subscription_admins: Specifies that the schedule scan notification will be is + sent to the subscription administrators. + :paramtype email_subscription_admins: bool + :keyword emails: Specifies an array of e-mail addresses to which the scan notification is sent. + :paramtype emails: list[str] + """ super(VulnerabilityAssessmentRecurringScansProperties, self).__init__(**kwargs) self.is_enabled = is_enabled self.email_subscription_admins = email_subscription_admins @@ -16713,6 +19581,8 @@ def __init__( self, **kwargs ): + """ + """ super(VulnerabilityAssessmentScanError, self).__init__(**kwargs) self.code = None self.message = None @@ -16780,6 +19650,8 @@ def __init__( self, **kwargs ): + """ + """ super(VulnerabilityAssessmentScanRecord, self).__init__(**kwargs) self.scan_id = None self.trigger_type = None @@ -16816,6 +19688,8 @@ def __init__( self, **kwargs ): + """ + """ super(VulnerabilityAssessmentScanRecordListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -16832,18 +19706,18 @@ class WorkloadClassifier(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param member_name: The workload classifier member name. - :type member_name: str - :param label: The workload classifier label. - :type label: str - :param context: The workload classifier context. - :type context: str - :param start_time: The workload classifier start time for classification. - :type start_time: str - :param end_time: The workload classifier end time for classification. - :type end_time: str - :param importance: The workload classifier importance. - :type importance: str + :ivar member_name: The workload classifier member name. + :vartype member_name: str + :ivar label: The workload classifier label. + :vartype label: str + :ivar context: The workload classifier context. + :vartype context: str + :ivar start_time: The workload classifier start time for classification. + :vartype start_time: str + :ivar end_time: The workload classifier end time for classification. + :vartype end_time: str + :ivar importance: The workload classifier importance. + :vartype importance: str """ _validation = { @@ -16875,6 +19749,20 @@ def __init__( importance: Optional[str] = None, **kwargs ): + """ + :keyword member_name: The workload classifier member name. + :paramtype member_name: str + :keyword label: The workload classifier label. + :paramtype label: str + :keyword context: The workload classifier context. + :paramtype context: str + :keyword start_time: The workload classifier start time for classification. + :paramtype start_time: str + :keyword end_time: The workload classifier end time for classification. + :paramtype end_time: str + :keyword importance: The workload classifier importance. + :paramtype importance: str + """ super(WorkloadClassifier, self).__init__(**kwargs) self.member_name = member_name self.label = label @@ -16909,6 +19797,8 @@ def __init__( self, **kwargs ): + """ + """ super(WorkloadClassifierListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -16925,18 +19815,18 @@ class WorkloadGroup(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param min_resource_percent: The workload group minimum percentage resource. - :type min_resource_percent: int - :param max_resource_percent: The workload group cap percentage resource. - :type max_resource_percent: int - :param min_resource_percent_per_request: The workload group request minimum grant percentage. - :type min_resource_percent_per_request: float - :param max_resource_percent_per_request: The workload group request maximum grant percentage. - :type max_resource_percent_per_request: float - :param importance: The workload group importance level. - :type importance: str - :param query_execution_timeout: The workload group query execution timeout. - :type query_execution_timeout: int + :ivar min_resource_percent: The workload group minimum percentage resource. + :vartype min_resource_percent: int + :ivar max_resource_percent: The workload group cap percentage resource. + :vartype max_resource_percent: int + :ivar min_resource_percent_per_request: The workload group request minimum grant percentage. + :vartype min_resource_percent_per_request: float + :ivar max_resource_percent_per_request: The workload group request maximum grant percentage. + :vartype max_resource_percent_per_request: float + :ivar importance: The workload group importance level. + :vartype importance: str + :ivar query_execution_timeout: The workload group query execution timeout. + :vartype query_execution_timeout: int """ _validation = { @@ -16968,6 +19858,20 @@ def __init__( query_execution_timeout: Optional[int] = None, **kwargs ): + """ + :keyword min_resource_percent: The workload group minimum percentage resource. + :paramtype min_resource_percent: int + :keyword max_resource_percent: The workload group cap percentage resource. + :paramtype max_resource_percent: int + :keyword min_resource_percent_per_request: The workload group request minimum grant percentage. + :paramtype min_resource_percent_per_request: float + :keyword max_resource_percent_per_request: The workload group request maximum grant percentage. + :paramtype max_resource_percent_per_request: float + :keyword importance: The workload group importance level. + :paramtype importance: str + :keyword query_execution_timeout: The workload group query execution timeout. + :paramtype query_execution_timeout: int + """ super(WorkloadGroup, self).__init__(**kwargs) self.min_resource_percent = min_resource_percent self.max_resource_percent = max_resource_percent @@ -17002,6 +19906,8 @@ def __init__( self, **kwargs ): + """ + """ super(WorkloadGroupListResult, self).__init__(**kwargs) self.value = None self.next_link = None 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 84179809aa20e..8e0820b34b1b5 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 @@ -6,37 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AdministratorName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AdministratorName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACTIVE_DIRECTORY = "ActiveDirectory" -class AdministratorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AdministratorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the sever administrator. """ ACTIVE_DIRECTORY = "ActiveDirectory" -class AdvisorStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AdvisorStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets the status of availability of this advisor to customers. Possible values are 'GA', 'PublicPreview', 'LimitedPublicPreview' and 'PrivatePreview'. """ @@ -46,7 +31,7 @@ class AdvisorStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LIMITED_PUBLIC_PREVIEW = "LimitedPublicPreview" PRIVATE_PREVIEW = "PrivatePreview" -class AggregationFunctionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AggregationFunctionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVG = "avg" MIN = "min" @@ -54,11 +39,11 @@ class AggregationFunctionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum STDEV = "stdev" SUM = "sum" -class AuthenticationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "Default" -class AutoExecuteStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutoExecuteStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets the auto-execute status (whether to let the system execute the recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled' """ @@ -67,7 +52,7 @@ class AutoExecuteStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DEFAULT = "Default" -class AutoExecuteStatusInheritedFrom(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutoExecuteStatusInheritedFrom(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets the resource from which current value of auto-execute status is inherited. Auto-execute status can be set on (and inherited from) different levels in the resource hierarchy. Possible values are 'Subscription', 'Server', 'ElasticPool', 'Database' and 'Default' (when status is @@ -80,7 +65,7 @@ class AutoExecuteStatusInheritedFrom(with_metaclass(_CaseInsensitiveEnumMeta, st ELASTIC_POOL = "ElasticPool" DATABASE = "Database" -class AutomaticTuningDisabledReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomaticTuningDisabledReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reason description if desired and actual state are different. """ @@ -92,7 +77,7 @@ class AutomaticTuningDisabledReason(with_metaclass(_CaseInsensitiveEnumMeta, str QUERY_STORE_READ_ONLY = "QueryStoreReadOnly" NOT_SUPPORTED = "NotSupported" -class AutomaticTuningMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomaticTuningMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Automatic tuning desired state. """ @@ -101,14 +86,14 @@ class AutomaticTuningMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AUTO = "Auto" UNSPECIFIED = "Unspecified" -class AutomaticTuningOptionModeActual(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomaticTuningOptionModeActual(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Automatic tuning option actual state. """ OFF = "Off" ON = "On" -class AutomaticTuningOptionModeDesired(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomaticTuningOptionModeDesired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Automatic tuning option desired state. """ @@ -116,7 +101,7 @@ class AutomaticTuningOptionModeDesired(with_metaclass(_CaseInsensitiveEnumMeta, ON = "On" DEFAULT = "Default" -class AutomaticTuningServerMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomaticTuningServerMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Automatic tuning desired state. """ @@ -124,7 +109,7 @@ class AutomaticTuningServerMode(with_metaclass(_CaseInsensitiveEnumMeta, str, En AUTO = "Auto" UNSPECIFIED = "Unspecified" -class AutomaticTuningServerReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomaticTuningServerReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reason description if desired and actual state are different. """ @@ -132,7 +117,7 @@ class AutomaticTuningServerReason(with_metaclass(_CaseInsensitiveEnumMeta, str, DISABLED = "Disabled" AUTO_CONFIGURED = "AutoConfigured" -class BackupStorageRedundancy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BackupStorageRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The storage account type used to store backups for this database. """ @@ -141,7 +126,7 @@ class BackupStorageRedundancy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum ZONE = "Zone" GEO_ZONE = "GeoZone" -class BlobAuditingPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BlobAuditingPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. """ @@ -149,7 +134,7 @@ class BlobAuditingPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum ENABLED = "Enabled" DISABLED = "Disabled" -class CapabilityGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CapabilityGroup(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUPPORTED_EDITIONS = "supportedEditions" SUPPORTED_ELASTIC_POOL_EDITIONS = "supportedElasticPoolEditions" @@ -157,7 +142,7 @@ class CapabilityGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUPPORTED_INSTANCE_POOL_EDITIONS = "supportedInstancePoolEditions" SUPPORTED_MANAGED_INSTANCE_EDITIONS = "supportedManagedInstanceEditions" -class CapabilityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CapabilityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the capability. """ @@ -166,14 +151,14 @@ class CapabilityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "Default" DISABLED = "Disabled" -class CatalogCollationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CatalogCollationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Collation of the metadata catalog. """ DATABASE_DEFAULT = "DATABASE_DEFAULT" SQL_LATIN1_GENERAL_CP1_CI_AS = "SQL_Latin1_General_CP1_CI_AS" -class CheckNameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CheckNameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason code explaining why the name is unavailable. Will be undefined if the name is available. """ @@ -181,7 +166,7 @@ class CheckNameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class ColumnDataType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ColumnDataType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The column data type. """ @@ -220,11 +205,11 @@ class ColumnDataType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): XML = "xml" SYSNAME = "sysname" -class ConnectionPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConnectionPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -233,7 +218,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class CreateMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreateMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the mode of database creation. Default: regular database creation. @@ -276,14 +261,14 @@ class CreateMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESTORE_LONG_TERM_RETENTION_BACKUP = "RestoreLongTermRetentionBackup" ONLINE_SECONDARY = "OnlineSecondary" -class DatabaseIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DatabaseIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type """ NONE = "None" USER_ASSIGNED = "UserAssigned" -class DatabaseLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DatabaseLicenseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The license type to apply for this database. ``LicenseIncluded`` if you need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid Benefit. """ @@ -291,7 +276,7 @@ class DatabaseLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LICENSE_INCLUDED = "LicenseIncluded" BASE_PRICE = "BasePrice" -class DatabaseReadScale(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DatabaseReadScale(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. @@ -300,13 +285,13 @@ class DatabaseReadScale(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class DatabaseState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DatabaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ALL = "All" LIVE = "Live" DELETED = "Deleted" -class DatabaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DatabaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the database. """ @@ -335,7 +320,7 @@ class DatabaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STOPPED = "Stopped" STARTING = "Starting" -class DataMaskingFunction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataMaskingFunction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The masking function that is used for the data masking rule. """ @@ -346,7 +331,7 @@ class DataMaskingFunction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SSN = "SSN" TEXT = "Text" -class DataMaskingRuleState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataMaskingRuleState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of @@ -356,18 +341,18 @@ class DataMaskingRuleState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" ENABLED = "Enabled" -class DataMaskingState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataMaskingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the data masking policy. """ DISABLED = "Disabled" ENABLED = "Enabled" -class DataWarehouseUserActivityName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataWarehouseUserActivityName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CURRENT = "current" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DayOfWeek(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Day of maintenance window. """ @@ -379,7 +364,7 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DiffBackupIntervalInHours(with_metaclass(_CaseInsensitiveEnumMeta, int, Enum)): +class DiffBackupIntervalInHours(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): """The differential backup interval in hours. This is how many interval hours between each differential backup will be supported. This is only applicable to live databases but not dropped databases. @@ -388,21 +373,21 @@ class DiffBackupIntervalInHours(with_metaclass(_CaseInsensitiveEnumMeta, int, En TWELVE = 12 TWENTY_FOUR = 24 -class DnsRefreshConfigurationPropertiesStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DnsRefreshConfigurationPropertiesStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the DNS refresh operation. """ SUCCEEDED = "Succeeded" FAILED = "Failed" -class ElasticPoolLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ElasticPoolLicenseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The license type to apply for this elastic pool. """ LICENSE_INCLUDED = "LicenseIncluded" BASE_PRICE = "BasePrice" -class ElasticPoolState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ElasticPoolState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the elastic pool. """ @@ -410,36 +395,29 @@ class ElasticPoolState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): READY = "Ready" DISABLED = "Disabled" -class EncryptionProtectorName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionProtectorName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CURRENT = "current" -class Enum60(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - ALL = "All" - ERROR = "Error" - WARNING = "Warning" - SUCCESS = "Success" - -class FailoverGroupReplicationRole(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FailoverGroupReplicationRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Local replication role of the failover group instance. """ PRIMARY = "Primary" SECONDARY = "Secondary" -class GeoBackupPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class GeoBackupPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "Default" -class GeoBackupPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class GeoBackupPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the geo backup policy. """ DISABLED = "Disabled" ENABLED = "Enabled" -class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. """ @@ -449,7 +427,7 @@ class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ImplementationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ImplementationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets the method in which this recommended action can be manually implemented. e.g., TSql, AzurePowerShell. """ @@ -457,14 +435,14 @@ class ImplementationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): T_SQL = "TSql" AZURE_POWER_SHELL = "AzurePowerShell" -class InstanceFailoverGroupReplicationRole(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InstanceFailoverGroupReplicationRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Local replication role of the failover group instance. """ PRIMARY = "Primary" SECONDARY = "Secondary" -class InstancePoolLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InstancePoolLicenseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The license type. Possible values are 'LicenseIncluded' (price for SQL license is included) and 'BasePrice' (without SQL license price). """ @@ -472,7 +450,7 @@ class InstancePoolLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum LICENSE_INCLUDED = "LicenseIncluded" BASE_PRICE = "BasePrice" -class IsRetryable(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IsRetryable(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets whether the error could be ignored and recommended action could be retried. Possible values are: Yes/No """ @@ -480,7 +458,7 @@ class IsRetryable(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): YES = "Yes" NO = "No" -class JobAgentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobAgentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the job agent. """ @@ -490,7 +468,7 @@ class JobAgentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETING = "Deleting" DISABLED = "Disabled" -class JobExecutionLifecycle(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobExecutionLifecycle(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The detailed state of the job execution. """ @@ -505,39 +483,39 @@ class JobExecutionLifecycle(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) CANCELED = "Canceled" SKIPPED = "Skipped" -class JobScheduleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobScheduleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Schedule interval type """ ONCE = "Once" RECURRING = "Recurring" -class JobStepActionSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStepActionSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source of the action to execute. """ INLINE = "Inline" -class JobStepActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStepActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of action being executed by the job step. """ T_SQL = "TSql" -class JobStepOutputType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStepOutputType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The output destination type. """ SQL_DATABASE = "SqlDatabase" -class JobTargetGroupMembershipType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobTargetGroupMembershipType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether the target is included or excluded from the group. """ INCLUDE = "Include" EXCLUDE = "Exclude" -class JobTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the target. """ @@ -547,18 +525,18 @@ class JobTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SQL_SHARD_MAP = "SqlShardMap" SQL_SERVER = "SqlServer" -class LedgerDigestUploadsName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LedgerDigestUploadsName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CURRENT = "current" -class LedgerDigestUploadsState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LedgerDigestUploadsState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the state of ledger digest upload. """ ENABLED = "Enabled" DISABLED = "Disabled" -class LogSizeUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LogSizeUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The units that the limit is expressed in. """ @@ -568,11 +546,11 @@ class LogSizeUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PETABYTES = "Petabytes" PERCENT = "Percent" -class LongTermRetentionPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LongTermRetentionPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" -class ManagedDatabaseCreateMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedDatabaseCreateMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from @@ -589,7 +567,7 @@ class ManagedDatabaseCreateMode(with_metaclass(_CaseInsensitiveEnumMeta, str, En RECOVERY = "Recovery" RESTORE_LONG_TERM_RETENTION_BACKUP = "RestoreLongTermRetentionBackup" -class ManagedDatabaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedDatabaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the database. """ @@ -601,13 +579,13 @@ class ManagedDatabaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) RESTORING = "Restoring" UPDATING = "Updating" -class ManagedInstanceAdministratorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedInstanceAdministratorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the managed instance administrator. """ ACTIVE_DIRECTORY = "ActiveDirectory" -class ManagedInstanceLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedInstanceLicenseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The license type. Possible values are 'LicenseIncluded' (regular price inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). """ @@ -615,11 +593,11 @@ class ManagedInstanceLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, E LICENSE_INCLUDED = "LicenseIncluded" BASE_PRICE = "BasePrice" -class ManagedInstanceLongTermRetentionPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedInstanceLongTermRetentionPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" -class ManagedInstancePropertiesProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedInstancePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CREATING = "Creating" DELETING = "Deleting" @@ -637,7 +615,7 @@ class ManagedInstancePropertiesProvisioningState(with_metaclass(_CaseInsensitive REGISTERING = "Registering" TIMED_OUT = "TimedOut" -class ManagedInstanceProxyOverride(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedInstanceProxyOverride(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Connection type used for connecting to the instance. """ @@ -645,7 +623,7 @@ class ManagedInstanceProxyOverride(with_metaclass(_CaseInsensitiveEnumMeta, str, REDIRECT = "Redirect" DEFAULT = "Default" -class ManagedServerCreateMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedServerCreateMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the mode of database creation. Default: Regular instance creation. @@ -657,11 +635,11 @@ class ManagedServerCreateMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum DEFAULT = "Default" POINT_IN_TIME_RESTORE = "PointInTimeRestore" -class ManagedShortTermRetentionPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedShortTermRetentionPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" -class ManagementOperationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagementOperationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operation state. """ @@ -672,7 +650,7 @@ class ManagementOperationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu CANCEL_IN_PROGRESS = "CancelInProgress" CANCELLED = "Cancelled" -class MaxSizeUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MaxSizeUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The units that the limit is expressed in. """ @@ -681,7 +659,7 @@ class MaxSizeUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): TERABYTES = "Terabytes" PETABYTES = "Petabytes" -class MetricType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CPU = "cpu" IO = "io" @@ -689,33 +667,33 @@ class MetricType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DURATION = "duration" DTU = "dtu" -class OperationMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Operation Mode. """ POLYBASE_IMPORT = "PolybaseImport" -class OperationOrigin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationOrigin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The intended executor of the operation. """ USER = "user" SYSTEM = "system" -class PauseDelayTimeUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PauseDelayTimeUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Unit of time that delay is expressed in """ MINUTES = "Minutes" -class PerformanceLevelUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PerformanceLevelUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Unit type used to measure performance level. """ DTU = "DTU" V_CORES = "VCores" -class PrimaryAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrimaryAggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The primary aggregation type defining how metric values are displayed. """ @@ -726,7 +704,7 @@ class PrimaryAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) MAXIMUM = "Maximum" TOTAL = "Total" -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Principal Type of the sever administrator. """ @@ -734,7 +712,7 @@ class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GROUP = "Group" APPLICATION = "Application" -class PrivateEndpointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of the private endpoint connection. """ @@ -744,13 +722,13 @@ class PrivateEndpointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, FAILED = "Failed" REJECTING = "Rejecting" -class PrivateLinkServiceConnectionStateActionsRequire(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStateActionsRequire(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The actions required for private link service connection. """ NONE = "None" -class PrivateLinkServiceConnectionStateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStateStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The private link service connection status. """ @@ -759,7 +737,7 @@ class PrivateLinkServiceConnectionStateStatus(with_metaclass(_CaseInsensitiveEnu REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The ARM provisioning state of the job execution. """ @@ -769,7 +747,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class QueryMetricUnitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QueryMetricUnitType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ @@ -778,21 +756,21 @@ class QueryMetricUnitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MICROSECONDS = "microseconds" COUNT = "count" -class QueryTimeGrainType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QueryTimeGrainType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Interval type (length). """ PT1_H = "PT1H" P1_D = "P1D" -class ReadOnlyEndpointFailoverPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReadOnlyEndpointFailoverPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Failover policy of the read-only endpoint for the failover group. """ DISABLED = "Disabled" ENABLED = "Enabled" -class ReadWriteEndpointFailoverPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReadWriteEndpointFailoverPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. """ @@ -800,7 +778,7 @@ class ReadWriteEndpointFailoverPolicy(with_metaclass(_CaseInsensitiveEnumMeta, s MANUAL = "Manual" AUTOMATIC = "Automatic" -class RecommendedActionCurrentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecommendedActionCurrentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Current state the recommended action is in. Some commonly used states are: Active -> recommended action is active and no action has been taken yet. Pending -> recommended action is approved for and is awaiting execution. Executing -> recommended action is being @@ -828,26 +806,26 @@ class RecommendedActionCurrentState(with_metaclass(_CaseInsensitiveEnumMeta, str SUCCESS = "Success" ERROR = "Error" -class RecommendedActionInitiatedBy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecommendedActionInitiatedBy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets if approval for applying this recommended action was given by user/system. """ USER = "User" SYSTEM = "System" -class RecommendedSensitivityLabelUpdateKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecommendedSensitivityLabelUpdateKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENABLE = "enable" DISABLE = "disable" -class ReplicationLinkType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationLinkType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Link type (GEO, NAMED). """ GEO = "GEO" NAMED = "NAMED" -class ReplicationRole(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Local replication role. """ @@ -857,7 +835,7 @@ class ReplicationRole(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SOURCE = "Source" COPY = "Copy" -class ReplicationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Replication state (PENDING, SEEDING, CATCHUP, SUSPENDED). """ @@ -866,23 +844,23 @@ class ReplicationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CATCH_UP = "CATCH_UP" SUSPENDED = "SUSPENDED" -class ReplicaType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReplicaType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "Primary" READABLE_SECONDARY = "ReadableSecondary" -class RestoreDetailsName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RestoreDetailsName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "Default" -class RestorePointType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of restore point """ CONTINUOUS = "CONTINUOUS" DISCRETE = "DISCRETE" -class SampleName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SampleName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the sample schema to apply when creating this database. """ @@ -890,18 +868,18 @@ class SampleName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): WIDE_WORLD_IMPORTERS_STD = "WideWorldImportersStd" WIDE_WORLD_IMPORTERS_FULL = "WideWorldImportersFull" -class SecondaryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SecondaryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The secondary type of the database if it is a secondary. Valid values are Geo and Named. """ GEO = "Geo" NAMED = "Named" -class SecurityAlertPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SecurityAlertPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "Default" -class SecurityAlertPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SecurityAlertPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. """ @@ -910,7 +888,7 @@ class SecurityAlertPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu ENABLED = "Enabled" DISABLED = "Disabled" -class SecurityAlertsPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SecurityAlertsPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. """ @@ -918,7 +896,7 @@ class SecurityAlertsPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, En ENABLED = "Enabled" DISABLED = "Disabled" -class SecurityEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SecurityEventType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the security event. """ @@ -926,7 +904,7 @@ class SecurityEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SQL_INJECTION_VULNERABILITY = "SqlInjectionVulnerability" SQL_INJECTION_EXPLOIT = "SqlInjectionExploit" -class SensitivityLabelRank(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SensitivityLabelRank(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NONE = "None" LOW = "Low" @@ -934,17 +912,17 @@ class SensitivityLabelRank(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): HIGH = "High" CRITICAL = "Critical" -class SensitivityLabelSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SensitivityLabelSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CURRENT = "current" RECOMMENDED = "recommended" -class SensitivityLabelUpdateKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SensitivityLabelUpdateKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SET = "set" REMOVE = "remove" -class ServerConnectionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerConnectionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The server connection type. """ @@ -952,14 +930,14 @@ class ServerConnectionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REDIRECT = "Redirect" PROXY = "Proxy" -class ServerKeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. """ SERVICE_MANAGED = "ServiceManaged" AZURE_KEY_VAULT = "AzureKeyVault" -class ServerNetworkAccessFlag(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerNetworkAccessFlag(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether or not public endpoint access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled' """ @@ -967,12 +945,12 @@ class ServerNetworkAccessFlag(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum ENABLED = "Enabled" DISABLED = "Disabled" -class ServerTrustGroupPropertiesTrustScopesItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerTrustGroupPropertiesTrustScopesItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): GLOBAL_TRANSACTIONS = "GlobalTransactions" SERVICE_BROKER = "ServiceBroker" -class ServerWorkspaceFeature(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerWorkspaceFeature(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether or not existing server has a workspace created and if it allows connection from workspace """ @@ -980,7 +958,7 @@ class ServerWorkspaceFeature(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) CONNECTED = "Connected" DISCONNECTED = "Disconnected" -class ServiceObjectiveName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServiceObjectiveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The serviceLevelObjective for SLO usage metric. """ @@ -1050,25 +1028,25 @@ class ServiceObjectiveName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DS2000 = "DS2000" ELASTIC_POOL = "ElasticPool" -class ServicePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServicePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Service principal type. """ NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" -class ShortTermRetentionPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ShortTermRetentionPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" -class SqlAgentConfigurationPropertiesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SqlAgentConfigurationPropertiesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of Sql Agent. """ ENABLED = "Enabled" DISABLED = "Disabled" -class StorageCapabilityStorageAccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StorageCapabilityStorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The storage account type for the database's backups. """ @@ -1076,14 +1054,14 @@ class StorageCapabilityStorageAccountType(with_metaclass(_CaseInsensitiveEnumMet LRS = "LRS" ZRS = "ZRS" -class StorageKeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StorageKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Storage key type. """ SHARED_ACCESS_KEY = "SharedAccessKey" STORAGE_ACCESS_KEY = "StorageAccessKey" -class SyncAgentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncAgentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of the sync agent. """ @@ -1091,14 +1069,14 @@ class SyncAgentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OFFLINE = "Offline" NEVER_CONNECTED = "NeverConnected" -class SyncConflictResolutionPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncConflictResolutionPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Conflict resolution policy of the sync group. """ HUB_WIN = "HubWin" MEMBER_WIN = "MemberWin" -class SyncDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sync direction of the sync member. """ @@ -1106,7 +1084,7 @@ class SyncDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ONE_WAY_MEMBER_TO_HUB = "OneWayMemberToHub" ONE_WAY_HUB_TO_MEMBER = "OneWayHubToMember" -class SyncGroupLogType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncGroupLogType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the sync group log. """ @@ -1115,7 +1093,7 @@ class SyncGroupLogType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" SUCCESS = "Success" -class SyncGroupState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncGroupState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sync state of the sync group. """ @@ -1125,14 +1103,21 @@ class SyncGroupState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PROGRESSING = "Progressing" GOOD = "Good" -class SyncMemberDbType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncGroupsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + ALL = "All" + ERROR = "Error" + WARNING = "Warning" + SUCCESS = "Success" + +class SyncMemberDbType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the sync agent linked database. """ AZURE_SQL_DATABASE = "AzureSqlDatabase" SQL_SERVER_DATABASE = "SqlServerDatabase" -class SyncMemberState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncMemberState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sync state of the sync member. """ @@ -1155,7 +1140,7 @@ class SyncMemberState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REPROVISION_FAILED = "ReprovisionFailed" UN_REPROVISIONED = "UnReprovisioned" -class TableTemporalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TableTemporalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The table temporal type. """ @@ -1163,18 +1148,18 @@ class TableTemporalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): HISTORY_TABLE = "HistoryTable" SYSTEM_VERSIONED_TEMPORAL_TABLE = "SystemVersionedTemporalTable" -class TransparentDataEncryptionName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TransparentDataEncryptionName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CURRENT = "current" -class TransparentDataEncryptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TransparentDataEncryptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the state of the transparent data encryption. """ ENABLED = "Enabled" DISABLED = "Disabled" -class UnitDefinitionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnitDefinitionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ @@ -1185,7 +1170,7 @@ class UnitDefinitionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): COUNT_PER_SECOND = "CountPerSecond" BYTES_PER_SECOND = "BytesPerSecond" -class UnitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnitType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ @@ -1196,7 +1181,7 @@ class UnitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): COUNT_PER_SECOND = "countPerSecond" BYTES_PER_SECOND = "bytesPerSecond" -class UpsertManagedServerOperationStepStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UpsertManagedServerOperationStepStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NOT_STARTED = "NotStarted" IN_PROGRESS = "InProgress" @@ -1205,7 +1190,7 @@ class UpsertManagedServerOperationStepStatus(with_metaclass(_CaseInsensitiveEnum FAILED = "Failed" CANCELED = "Canceled" -class VirtualNetworkRuleState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VirtualNetworkRuleState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Virtual Network Rule State """ @@ -1216,16 +1201,16 @@ class VirtualNetworkRuleState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum DELETING = "Deleting" UNKNOWN = "Unknown" -class VulnerabilityAssessmentName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VulnerabilityAssessmentName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" -class VulnerabilityAssessmentPolicyBaselineName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VulnerabilityAssessmentPolicyBaselineName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MASTER = "master" DEFAULT = "default" -class VulnerabilityAssessmentScanState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VulnerabilityAssessmentScanState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scan status. """ @@ -1234,7 +1219,7 @@ class VulnerabilityAssessmentScanState(with_metaclass(_CaseInsensitiveEnumMeta, FAILED_TO_RUN = "FailedToRun" IN_PROGRESS = "InProgress" -class VulnerabilityAssessmentScanTriggerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VulnerabilityAssessmentScanTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scan trigger type. """ 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 f990cc3c49eaa..8d0b2ee774068 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 @@ -81,7 +81,6 @@ from ._managed_restorable_dropped_database_backup_short_term_retention_policies_operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations from ._managed_server_security_alert_policies_operations import ManagedServerSecurityAlertPoliciesOperations from ._operations import Operations -from ._operations_health_operations import OperationsHealthOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._recoverable_managed_databases_operations import RecoverableManagedDatabasesOperations @@ -125,6 +124,7 @@ from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations from ._server_connection_policies_operations import ServerConnectionPoliciesOperations +from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations __all__ = [ 'RecoverableDatabasesOperations', @@ -202,7 +202,6 @@ 'ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations', 'ManagedServerSecurityAlertPoliciesOperations', 'Operations', - 'OperationsHealthOperations', 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', 'RecoverableManagedDatabasesOperations', @@ -246,4 +245,5 @@ 'RestorableDroppedDatabasesOperations', 'RestorableDroppedManagedDatabasesOperations', 'ServerConnectionPoliciesOperations', + 'IPv6FirewallRulesOperations', ] diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_backup_short_term_retention_policies_operations.py index 2ba2ce255fb35..a8e9f2c3bc99e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_backup_short_term_retention_policies_operations.py @@ -5,25 +5,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BackupShortTermRetentionPoliciesOperations(object): """BackupShortTermRetentionPoliciesOperations operations. @@ -47,15 +222,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ShortTermRetentionPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.BackupShortTermRetentionPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + **kwargs: Any + ) -> "_models.BackupShortTermRetentionPolicy": """Gets a database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,29 +252,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,51 +278,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ShortTermRetentionPolicyName"] - parameters, # type: "_models.BackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BackupShortTermRetentionPolicy"] + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + parameters: "_models.BackupShortTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.BackupShortTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupShortTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,18 +329,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ShortTermRetentionPolicyName"] - parameters, # type: "_models.BackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BackupShortTermRetentionPolicy"] + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + parameters: "_models.BackupShortTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.BackupShortTermRetentionPolicy"]: """Updates a database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -200,15 +358,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy :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. + :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 BackupShortTermRetentionPolicy or the result of cls(response) + :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 BackupShortTermRetentionPolicy or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -222,29 +384,21 @@ def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,51 +410,41 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ShortTermRetentionPolicyName"] - parameters, # type: "_models.BackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BackupShortTermRetentionPolicy"] + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + parameters: "_models.BackupShortTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.BackupShortTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupShortTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,18 +460,20 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ShortTermRetentionPolicyName"] - parameters, # type: "_models.BackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BackupShortTermRetentionPolicy"] + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.ShortTermRetentionPolicyName"], + parameters: "_models.BackupShortTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.BackupShortTermRetentionPolicy"]: """Updates a database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -343,15 +489,19 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy :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. + :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 BackupShortTermRetentionPolicy or the result of cls(response) + :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 BackupShortTermRetentionPolicy or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -365,29 +515,21 @@ def begin_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -399,16 +541,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BackupShortTermRetentionPolicyListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.BackupShortTermRetentionPolicyListResult"]: """Gets a database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -419,8 +562,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupShortTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicyListResult] + :return: An iterator like instance of either BackupShortTermRetentionPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupShortTermRetentionPolicyListResult"] @@ -428,37 +573,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BackupShortTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("BackupShortTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -476,6 +619,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_capabilities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_capabilities_operations.py index 8e773ea7bf4f1..2a11bd178f7ee 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_capabilities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_capabilities_operations.py @@ -5,22 +5,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_location_request( + location_name: str, + subscription_id: str, + *, + include: Optional[Union[str, "_models.CapabilityGroup"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include is not None: + query_parameters['include'] = _SERIALIZER.query("include", include, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CapabilitiesOperations(object): """CapabilitiesOperations operations. @@ -44,13 +83,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_location( self, - location_name, # type: str - include=None, # type: Optional[Union[str, "_models.CapabilityGroup"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.LocationCapabilities" + location_name: str, + include: Optional[Union[str, "_models.CapabilityGroup"]] = None, + **kwargs: Any + ) -> "_models.LocationCapabilities": """Gets the subscription capabilities available for the specified location. :param location_name: The location name whose capabilities are retrieved. @@ -67,28 +106,17 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if include is not None: - query_parameters['include'] = self._serialize.query("include", include, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + include=include, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,4 +130,6 @@ def list_by_location( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py index 233f71e2fdcd0..91f0335db0ce4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py @@ -5,22 +5,112 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + data_masking_policy_name = "Default" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + data_masking_policy_name = "Default" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DataMaskingPoliciesOperations(object): """DataMaskingPoliciesOperations operations. @@ -44,15 +134,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.DataMaskingPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataMaskingPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.DataMaskingPolicy", + **kwargs: Any + ) -> "_models.DataMaskingPolicy": """Creates or updates a database data masking policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,35 +164,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DataMaskingPolicy') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataMaskingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -116,16 +194,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataMaskingPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.DataMaskingPolicy": """Gets a database data masking policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -145,30 +225,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,4 +250,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py index 6e7b482b4d7c6..be47554737628 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py @@ -5,23 +5,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + data_masking_policy_name = "Default" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), + "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + data_masking_policy_name = "Default" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DataMaskingRulesOperations(object): """DataMaskingRulesOperations operations. @@ -45,16 +137,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - data_masking_rule_name, # type: str - parameters, # type: "_models.DataMaskingRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataMaskingRule" + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_rule_name: str, + parameters: "_models.DataMaskingRule", + **kwargs: Any + ) -> "_models.DataMaskingRule": """Creates or updates a database data masking rule. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -78,36 +170,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - 'dataMaskingRuleName': self._serialize.url("data_masking_rule_name", data_masking_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DataMaskingRule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_masking_rule_name=data_masking_rule_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataMaskingRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -125,16 +205,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataMaskingRuleListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DataMaskingRuleListResult"]: """Gets a list of database data masking rules. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -145,7 +227,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataMaskingRuleListResult or the result of cls(response) + :return: An iterator like instance of either DataMaskingRuleListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataMaskingRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -154,39 +237,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - data_masking_policy_name = "Default" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataMaskingPolicyName': self._serialize.url("data_masking_policy_name", data_masking_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataMaskingRuleListResult', pipeline_response) + deserialized = self._deserialize("DataMaskingRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,6 +283,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_warehouse_user_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_warehouse_user_activities_operations.py index 4d5da49affbe6..453a6425b693e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_warehouse_user_activities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_warehouse_user_activities_operations.py @@ -5,23 +5,101 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + data_warehouse_user_activity_name: Union[str, "_models.DataWarehouseUserActivityName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "dataWarehouseUserActivityName": _SERIALIZER.url("data_warehouse_user_activity_name", data_warehouse_user_activity_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DataWarehouseUserActivitiesOperations(object): """DataWarehouseUserActivitiesOperations operations. @@ -45,15 +123,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - data_warehouse_user_activity_name, # type: Union[str, "_models.DataWarehouseUserActivityName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataWarehouseUserActivities" + resource_group_name: str, + server_name: str, + database_name: str, + data_warehouse_user_activity_name: Union[str, "_models.DataWarehouseUserActivityName"], + **kwargs: Any + ) -> "_models.DataWarehouseUserActivities": """Gets the user activities of a data warehouse which includes running and suspended queries. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -64,7 +142,8 @@ def get( :param database_name: The name of the database. :type database_name: str :param data_warehouse_user_activity_name: The activity name of the data warehouse. - :type data_warehouse_user_activity_name: str or ~azure.mgmt.sql.models.DataWarehouseUserActivityName + :type data_warehouse_user_activity_name: str or + ~azure.mgmt.sql.models.DataWarehouseUserActivityName :keyword callable cls: A custom type or function that will be passed the direct response :return: DataWarehouseUserActivities, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataWarehouseUserActivities @@ -75,29 +154,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'dataWarehouseUserActivityName': self._serialize.url("data_warehouse_user_activity_name", data_warehouse_user_activity_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_warehouse_user_activity_name=data_warehouse_user_activity_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,16 +180,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataWarehouseUserActivitiesListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DataWarehouseUserActivitiesListResult"]: """List the user activities of a data warehouse which includes running and suspended queries. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -131,8 +202,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataWarehouseUserActivitiesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivitiesListResult] + :return: An iterator like instance of either DataWarehouseUserActivitiesListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataWarehouseUserActivitiesListResult"] @@ -140,37 +213,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataWarehouseUserActivitiesListResult', pipeline_response) + deserialized = self._deserialize("DataWarehouseUserActivitiesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -188,6 +259,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advisors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advisors_operations.py index 3cbbeff7e02fd..aec30bf47ef25 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advisors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advisors_operations.py @@ -5,22 +5,153 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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, + server_name: str, + database_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class DatabaseAdvisorsOperations(object): """DatabaseAdvisorsOperations operations. @@ -44,15 +175,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> List["_models.Advisor"] + resource_group_name: str, + server_name: str, + database_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> List["_models.Advisor"]: """Gets a list of database advisors. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,30 +205,19 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,17 +231,19 @@ def list_by_database( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - advisor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Advisor" + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + **kwargs: Any + ) -> "_models.Advisor": """Gets a database advisor. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -143,29 +265,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,18 +291,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - advisor_name, # type: str - parameters, # type: "_models.Advisor" - **kwargs # type: Any - ): - # type: (...) -> "_models.Advisor" + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: "_models.Advisor", + **kwargs: Any + ) -> "_models.Advisor": """Updates a database advisor. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -214,34 +328,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Advisor') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Advisor') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -255,4 +359,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py index aea6dbe3e44ca..797b42dda4870 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py @@ -5,22 +5,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class DatabaseAutomaticTuningOperations(object): """DatabaseAutomaticTuningOperations operations. @@ -44,14 +130,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAutomaticTuning" + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.DatabaseAutomaticTuning": """Gets a database's automatic tuning. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,28 +157,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,17 +182,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.DatabaseAutomaticTuning" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAutomaticTuning" + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.DatabaseAutomaticTuning", + **kwargs: Any + ) -> "_models.DatabaseAutomaticTuning": """Update automatic tuning properties for target database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -138,33 +216,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseAutomaticTuning') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseAutomaticTuning') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -178,4 +246,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py index f6c13207bb6a3..187a99f2a5070 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py @@ -5,23 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseBlobAuditingPoliciesOperations(object): """DatabaseBlobAuditingPoliciesOperations operations. @@ -45,14 +172,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseBlobAuditingPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.DatabaseBlobAuditingPolicy": """Gets a database's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,30 +199,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,17 +224,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.DatabaseBlobAuditingPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseBlobAuditingPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.DatabaseBlobAuditingPolicy", + **kwargs: Any + ) -> "_models.DatabaseBlobAuditingPolicy": """Creates or updates a database's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -141,35 +258,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseBlobAuditingPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,16 +292,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseBlobAuditingPolicyListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseBlobAuditingPolicyListResult"]: """Lists auditing settings of a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -207,8 +314,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseBlobAuditingPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicyListResult] + :return: An iterator like instance of either DatabaseBlobAuditingPolicyListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseBlobAuditingPolicyListResult"] @@ -216,37 +325,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("DatabaseBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -264,6 +371,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_columns_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_columns_operations.py index b1b24e3d976d6..c4fa947974a8e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_columns_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_columns_operations.py @@ -5,23 +5,166 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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, + server_name: str, + database_name: str, + subscription_id: str, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/columns') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if schema is not None: + query_parameters['schema'] = [_SERIALIZER.query("schema", q, 'str') if q is not None else '' for q in schema] + if table is not None: + query_parameters['table'] = [_SERIALIZER.query("table", q, 'str') if q is not None else '' for q in table] + if column is not None: + query_parameters['column'] = [_SERIALIZER.query("column", q, 'str') if q is not None else '' for q in column] + if order_by is not None: + query_parameters['orderBy'] = [_SERIALIZER.query("order_by", q, 'str') if q is not None else '' for q in order_by] + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_table_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseColumnsOperations(object): """DatabaseColumnsOperations operations. @@ -45,19 +188,19 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema=None, # type: Optional[List[str]] - table=None, # type: Optional[List[str]] - column=None, # type: Optional[List[str]] - order_by=None, # type: Optional[List[str]] - skiptoken=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseColumnListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseColumnListResult"]: """List database columns. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -78,7 +221,8 @@ def list_by_database( :param skiptoken: An opaque token that identifies a starting point in the collection. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -87,47 +231,45 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if schema is not None: - query_parameters['schema'] = [self._serialize.query("schema", q, 'str') if q is not None else '' for q in schema] - if table is not None: - query_parameters['table'] = [self._serialize.query("table", q, 'str') if q is not None else '' for q in table] - if column is not None: - query_parameters['column'] = [self._serialize.query("column", q, 'str') if q is not None else '' for q in column] - if order_by is not None: - query_parameters['orderBy'] = [self._serialize.query("order_by", q, 'str') if q is not None else '' for q in order_by] - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -145,22 +287,23 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/columns'} # type: ignore + @distributed_trace def list_by_table( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseColumnListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseColumnListResult"]: """List database columns. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -177,7 +320,8 @@ def list_by_table( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -186,41 +330,41 @@ def list_by_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_table.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -238,22 +382,23 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseColumn" + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> "_models.DatabaseColumn": """Get database column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -279,31 +424,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -317,4 +452,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py index c4bdcd77b6595..62de67ea50f0c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py @@ -5,25 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseExtensionsOperations(object): """DatabaseExtensionsOperations operations. @@ -47,15 +168,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + **kwargs: Any + ) -> None: """Gets a database extension. This will return resource not found as it is not supported. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,27 +198,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,49 +223,39 @@ def get( get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - extension_name, # type: str - parameters, # type: "_models.DatabaseExtensions" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ImportExportExtensionsOperationResult"] + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: "_models.DatabaseExtensions", + **kwargs: Any + ) -> Optional["_models.ImportExportExtensionsOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportExtensionsOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseExtensions') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseExtensions') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,18 +271,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - extension_name, # type: str - parameters, # type: "_models.DatabaseExtensions" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ImportExportExtensionsOperationResult"] + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: "_models.DatabaseExtensions", + **kwargs: Any + ) -> LROPoller["_models.ImportExportExtensionsOperationResult"]: """Perform a database extension operation, like polybase import. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -195,15 +300,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions :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. + :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 ImportExportExtensionsOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ImportExportExtensionsOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportExtensionsOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -217,29 +327,21 @@ def begin_create_or_update( database_name=database_name, extension_name=extension_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportExtensionsOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -251,16 +353,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ImportExportExtensionsOperationListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.ImportExportExtensionsOperationListResult"]: """List database extension. This will return an empty list as it is not supported. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -271,8 +374,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportExportExtensionsOperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationListResult] + :return: An iterator like instance of either ImportExportExtensionsOperationListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportExtensionsOperationListResult"] @@ -280,37 +385,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ImportExportExtensionsOperationListResult', pipeline_response) + deserialized = self._deserialize("ImportExportExtensionsOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -328,6 +431,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_operations_operations.py index 23f3fe4d2fbef..2fdb5b6de59c0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_operations_operations.py @@ -5,23 +5,95 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_cancel_request( + resource_group_name: str, + server_name: str, + database_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseOperationsOperations(object): """DatabaseOperationsOperations operations. @@ -45,15 +117,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def cancel( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + operation_id: str, + **kwargs: Any + ) -> None: """Cancels the asynchronous operation on the database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -75,27 +147,19 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,14 +172,15 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseOperationListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseOperationListResult"]: """Gets a list of operations performed on the database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -126,7 +191,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseOperationListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseOperationListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -135,37 +201,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseOperationListResult', pipeline_response) + deserialized = self._deserialize("DatabaseOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,6 +247,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_recommended_actions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_recommended_actions_operations.py index bc8d5351657e6..3871841f6a42f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_recommended_actions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_recommended_actions_operations.py @@ -5,22 +5,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_database_advisor_request( + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, 'str'), + "recommendedActionName": _SERIALIZER.url("recommended_action_name", recommended_action_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, 'str'), + "recommendedActionName": _SERIALIZER.url("recommended_action_name", recommended_action_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class DatabaseRecommendedActionsOperations(object): """DatabaseRecommendedActionsOperations operations. @@ -44,15 +177,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database_advisor( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - advisor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.RecommendedAction"] + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + **kwargs: Any + ) -> List["_models.RecommendedAction"]: """Gets list of Database Recommended Actions. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,29 +207,19 @@ def list_by_database_advisor( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_database_advisor.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_database_advisor_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database_advisor.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,18 +233,20 @@ def list_by_database_advisor( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_database_advisor.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - advisor_name, # type: str - recommended_action_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RecommendedAction" + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + **kwargs: Any + ) -> "_models.RecommendedAction": """Gets a database recommended action. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -145,30 +270,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'recommendedActionName': self._serialize.url("recommended_action_name", recommended_action_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,19 +297,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - advisor_name, # type: str - recommended_action_name, # type: str - parameters, # type: "_models.RecommendedAction" - **kwargs # type: Any - ): - # type: (...) -> "_models.RecommendedAction" + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: "_models.RecommendedAction", + **kwargs: Any + ) -> "_models.RecommendedAction": """Updates a database recommended action. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -220,35 +337,25 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'recommendedActionName': self._serialize.url("recommended_action_name", recommended_action_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'RecommendedAction') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecommendedAction') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -262,4 +369,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py index 80e8905c22ee3..7c2883576f9b8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py @@ -5,23 +5,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseSchemasOperations(object): """DatabaseSchemasOperations operations. @@ -45,15 +127,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseSchemaListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseSchemaListResult"]: """List database schemas. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -66,7 +148,8 @@ def list_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseSchemaListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseSchemaListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSchemaListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -75,39 +158,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseSchemaListResult', pipeline_response) + deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,20 +206,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseSchema" + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + **kwargs: Any + ) -> "_models.DatabaseSchema": """Get database schema. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -160,29 +242,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -196,4 +268,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py index 673833c13eaab..a9c50c02cc82b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py @@ -5,23 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseSecurityAlertPoliciesOperations(object): """DatabaseSecurityAlertPoliciesOperations operations. @@ -45,15 +172,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseSecurityAlertPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + **kwargs: Any + ) -> "_models.DatabaseSecurityAlertPolicy": """Gets a database's security alert policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -75,29 +202,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,18 +228,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - parameters, # type: "_models.DatabaseSecurityAlertPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseSecurityAlertPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: "_models.DatabaseSecurityAlertPolicy", + **kwargs: Any + ) -> "_models.DatabaseSecurityAlertPolicy": """Creates or updates a database's security alert policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -146,34 +265,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseSecurityAlertPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,16 +300,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseSecurityAlertListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseSecurityAlertListResult"]: """Gets a list of database's security alert policies. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -211,7 +322,8 @@ def list_by_database( :param database_name: The name of the database for which the security alert policy is defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseSecurityAlertListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseSecurityAlertListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -220,37 +332,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseSecurityAlertListResult', pipeline_response) + deserialized = self._deserialize("DatabaseSecurityAlertListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -268,6 +378,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_tables_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_tables_operations.py index 530b24117b75c..e30c395a8a738 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_tables_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_tables_operations.py @@ -5,23 +5,109 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_schema_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseTablesOperations(object): """DatabaseTablesOperations operations. @@ -45,16 +131,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_schema( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseTableListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseTableListResult"]: """List database tables. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -69,7 +155,8 @@ def list_by_schema( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseTableListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseTableListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseTableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -78,40 +165,39 @@ def list_by_schema( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_schema.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_schema.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseTableListResult', pipeline_response) + deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,21 +215,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseTable" + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + **kwargs: Any + ) -> "_models.DatabaseTable": """Get database table. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -167,30 +254,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,4 +281,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py index ddedb04c40c14..cb11206b736ff 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py @@ -5,23 +5,62 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseUsagesOperations(object): """DatabaseUsagesOperations operations. @@ -45,14 +84,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseUsageListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseUsageListResult"]: """Gets database usages. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -63,7 +102,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseUsageListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseUsageListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseUsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -72,37 +112,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseUsageListResult', pipeline_response) + deserialized = self._deserialize("DatabaseUsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,6 +158,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py index e011622de0dbe..5d339804667d2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py @@ -5,22 +5,157 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class DatabaseVulnerabilityAssessmentRuleBaselinesOperations(object): """DatabaseVulnerabilityAssessmentRuleBaselinesOperations operations. @@ -44,17 +179,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - rule_id, # type: str - baseline_name, # type: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline" + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline": """Gets a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -82,31 +217,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -120,20 +245,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - rule_id, # type: str - baseline_name, # type: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"] - parameters, # type: "_models.DatabaseVulnerabilityAssessmentRuleBaseline" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline" + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + parameters: "_models.DatabaseVulnerabilityAssessmentRuleBaseline", + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline": """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -163,36 +290,26 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -206,19 +323,21 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - rule_id, # type: str - baseline_name, # type: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + **kwargs: Any + ) -> None: """Removes the database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -246,29 +365,21 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -280,3 +391,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py index def15f6d65ba1..5c1a740d6f6c2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py @@ -5,25 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_initiate_scan_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseVulnerabilityAssessmentScansOperations(object): """DatabaseVulnerabilityAssessmentScansOperations operations. @@ -49,41 +207,32 @@ def __init__(self, client, config, serializer, deserializer): def _initiate_scan_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._initiate_scan_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_initiate_scan_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self._initiate_scan_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,16 +245,17 @@ def _initiate_scan_initial( _initiate_scan_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + + @distributed_trace def begin_initiate_scan( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> LROPoller[None]: """Executes a Vulnerability Assessment database scan. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -121,15 +271,17 @@ def begin_initiate_scan( :type scan_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -146,24 +298,14 @@ def begin_initiate_scan( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -175,17 +317,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_initiate_scan.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VulnerabilityAssessmentScanRecordListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> Iterable["_models.VulnerabilityAssessmentScanRecordListResult"]: """Lists the vulnerability assessment scans of a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -198,8 +341,10 @@ def list_by_database( :param vulnerability_assessment_name: The name of the vulnerability assessment. :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] + :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecordListResult"] @@ -207,38 +352,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VulnerabilityAssessmentScanRecordListResult', pipeline_response) + deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -256,21 +400,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VulnerabilityAssessmentScanRecord" + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> "_models.VulnerabilityAssessmentScanRecord": """Gets a vulnerability assessment scan record of a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -294,30 +439,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,18 +466,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}'} # type: ignore + + @distributed_trace def export( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessmentScansExport" + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessmentScansExport": """Convert an existing scan result to a human readable format. If already exists nothing happens. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -366,30 +503,20 @@ def export( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.export.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.export.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -407,4 +534,6 @@ def export( return cls(pipeline_response, deserialized, {}) return deserialized + export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py index f278e697e4abf..fa54d3ecda00e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py @@ -5,23 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseVulnerabilityAssessmentsOperations(object): """DatabaseVulnerabilityAssessmentsOperations operations. @@ -45,15 +205,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessment" + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessment": """Gets the database's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -76,29 +236,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,18 +262,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - parameters, # type: "_models.DatabaseVulnerabilityAssessment" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessment" + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: "_models.DatabaseVulnerabilityAssessment", + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessment": """Creates or updates the database's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,34 +300,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -193,17 +335,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> None: """Removes the database's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -226,27 +370,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -259,14 +395,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseVulnerabilityAssessmentListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseVulnerabilityAssessmentListResult"]: """Lists the vulnerability assessment policies associated with a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -278,8 +415,10 @@ def list_by_database( are defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] + :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseVulnerabilityAssessmentListResult"] @@ -287,37 +426,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -335,6 +472,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py index 6de290589a12c..3efe2527ae7c4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py @@ -5,25 +5,652 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_metric_definitions_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_elastic_pool_request( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_failover_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if replica_type is not None: + query_parameters['replicaType'] = _SERIALIZER.query("replica_type", replica_type, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_inaccessible_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_pause_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_resume_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_upgrade_data_warehouse_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_rename_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_method_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_export_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class DatabasesOperations(object): """DatabasesOperations operations. @@ -47,15 +674,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.MetricListResult"]: """Returns database metrics. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,38 +704,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,19 +752,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics'} # type: ignore + @distributed_trace def list_metric_definitions( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionListResult"]: """Returns database metric definitions. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -149,7 +776,8 @@ def list_metric_definitions( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionListResult or the result of cls(response) + :return: An iterator like instance of either MetricDefinitionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.MetricDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -158,37 +786,35 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricDefinitionListResult', pipeline_response) + deserialized = self._deserialize("MetricDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -206,19 +832,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metric_definitions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - skip_token=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseListResult"] + resource_group_name: str, + server_name: str, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseListResult"]: """Gets a list of databases. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -238,38 +865,35 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseListResult', pipeline_response) + deserialized = self._deserialize("DatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -287,19 +911,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Database" + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.Database": """Gets a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -319,28 +944,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -354,49 +969,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.Database" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.Database", + **kwargs: Any + ) -> Optional["_models.Database"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Database') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Database') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -415,17 +1021,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.Database" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.Database", + **kwargs: Any + ) -> LROPoller["_models.Database"]: """Creates a new database or updates an existing database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -439,15 +1047,18 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.Database :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -460,28 +1071,21 @@ def begin_create_or_update( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -493,41 +1097,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -540,14 +1136,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -559,15 +1156,17 @@ def begin_delete( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -582,22 +1181,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -609,49 +1200,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.DatabaseUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.DatabaseUpdate", + **kwargs: Any + ) -> Optional["_models.Database"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -667,17 +1248,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.DatabaseUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.DatabaseUpdate", + **kwargs: Any + ) -> LROPoller["_models.Database"]: """Updates an existing database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -691,15 +1274,18 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -712,28 +1298,21 @@ def begin_update( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -745,16 +1324,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore + @distributed_trace def list_by_elastic_pool( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseListResult"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseListResult"]: """Gets a list of databases in an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -774,37 +1354,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseListResult', pipeline_response) + deserialized = self._deserialize("DatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -822,6 +1400,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -829,40 +1408,30 @@ def get_next(next_link=None): def _failover_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - replica_type=None, # type: Optional[Union[str, "_models.ReplicaType"]] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if replica_type is not None: - query_parameters['replicaType'] = self._serialize.query("replica_type", replica_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -875,15 +1444,16 @@ def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore + + @distributed_trace def begin_failover( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - replica_type=None, # type: Optional[Union[str, "_models.ReplicaType"]] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + **kwargs: Any + ) -> LROPoller[None]: """Failovers a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -897,15 +1467,17 @@ def begin_failover( :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -921,22 +1493,14 @@ def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -948,15 +1512,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore + @distributed_trace def list_inaccessible_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseListResult"]: """Gets a list of inaccessible databases in a logical server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -974,36 +1539,33 @@ def list_inaccessible_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_inaccessible_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_inaccessible_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseListResult', pipeline_response) + deserialized = self._deserialize("DatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1021,6 +1583,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1028,39 +1591,28 @@ def get_next(next_link=None): def _pause_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.Database"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._pause_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_pause_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._pause_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1076,16 +1628,18 @@ def _pause_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _pause_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore + + @distributed_trace def begin_pause( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller["_models.Database"]: """Pauses a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1097,15 +1651,17 @@ def begin_pause( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -1120,25 +1676,17 @@ def begin_pause( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1150,43 +1698,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_pause.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore def _resume_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.Database"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._resume_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_resume_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._resume_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1202,16 +1740,18 @@ def _resume_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore + + @distributed_trace def begin_resume( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Database"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller["_models.Database"]: """Resumes a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1223,15 +1763,17 @@ def begin_resume( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', @@ -1246,25 +1788,17 @@ def begin_resume( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Database', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1276,41 +1810,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore def _upgrade_data_warehouse_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._upgrade_data_warehouse_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_upgrade_data_warehouse_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._upgrade_data_warehouse_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1323,14 +1849,15 @@ def _upgrade_data_warehouse_initial( _upgrade_data_warehouse_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + + @distributed_trace def begin_upgrade_data_warehouse( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Upgrades a data warehouse. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1342,15 +1869,17 @@ def begin_upgrade_data_warehouse( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1365,22 +1894,14 @@ def begin_upgrade_data_warehouse( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1392,17 +1913,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_upgrade_data_warehouse.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + @distributed_trace def rename( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.ResourceMoveDefinition" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.ResourceMoveDefinition", + **kwargs: Any + ) -> None: """Renames a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1424,31 +1946,23 @@ def rename( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.rename.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceMoveDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_rename_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.rename.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceMoveDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1461,47 +1975,37 @@ def rename( rename.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move'} # type: ignore + def _import_method_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.ImportExistingDatabaseDefinition" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ImportExportOperationResult"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.ImportExistingDatabaseDefinition", + **kwargs: Any + ) -> Optional["_models.ImportExportOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._import_method_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_import_method_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._import_method_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1517,17 +2021,19 @@ def _import_method_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore + + @distributed_trace def begin_import_method( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.ImportExistingDatabaseDefinition" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ImportExportOperationResult"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.ImportExistingDatabaseDefinition", + **kwargs: Any + ) -> LROPoller["_models.ImportExportOperationResult"]: """Imports a bacpac into a new database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1541,15 +2047,19 @@ def begin_import_method( :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 ImportExportOperationResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ImportExportOperationResult or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1562,28 +2072,21 @@ def begin_import_method( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1595,49 +2098,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore def _export_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.ExportDatabaseDefinition" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ImportExportOperationResult"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.ExportDatabaseDefinition", + **kwargs: Any + ) -> Optional["_models.ImportExportOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ExportDatabaseDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._export_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportDatabaseDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1653,17 +2146,19 @@ def _export_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore + + @distributed_trace def begin_export( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.ExportDatabaseDefinition" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ImportExportOperationResult"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.ExportDatabaseDefinition", + **kwargs: Any + ) -> LROPoller["_models.ImportExportOperationResult"]: """Exports a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1677,15 +2172,19 @@ def begin_export( :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 ImportExportOperationResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ImportExportOperationResult or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1698,28 +2197,21 @@ def begin_export( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1731,4 +2223,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_deleted_servers_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_deleted_servers_operations.py index 72ed3b192ee42..1248cb0214c35 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_deleted_servers_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_deleted_servers_operations.py @@ -5,25 +5,161 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + location_name: str, + deleted_server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "deletedServerName": _SERIALIZER.url("deleted_server_name", deleted_server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_location_request( + location_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_recover_request_initial( + location_name: str, + deleted_server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "deletedServerName": _SERIALIZER.url("deleted_server_name", deleted_server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DeletedServersOperations(object): """DeletedServersOperations operations. @@ -47,15 +183,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DeletedServerListResult"] + **kwargs: Any + ) -> Iterable["_models.DeletedServerListResult"]: """Gets a list of all deleted servers in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedServerListResult or the result of cls(response) + :return: An iterator like instance of either DeletedServerListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DeletedServerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -64,34 +201,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeletedServerListResult', pipeline_response) + deserialized = self._deserialize("DeletedServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,18 +241,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers'} # type: ignore + @distributed_trace def get( self, - location_name, # type: str - deleted_server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DeletedServer" + location_name: str, + deleted_server_name: str, + **kwargs: Any + ) -> "_models.DeletedServer": """Gets a deleted server. :param location_name: The name of the region where the resource is located. @@ -137,27 +270,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'deletedServerName': self._serialize.url("deleted_server_name", deleted_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -171,20 +294,23 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}'} # type: ignore + + @distributed_trace def list_by_location( self, - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DeletedServerListResult"] + location_name: str, + **kwargs: Any + ) -> Iterable["_models.DeletedServerListResult"]: """Gets a list of deleted servers for a location. :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedServerListResult or the result of cls(response) + :return: An iterator like instance of either DeletedServerListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DeletedServerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -193,35 +319,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeletedServerListResult', pipeline_response) + deserialized = self._deserialize("DeletedServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -239,6 +361,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -246,37 +369,26 @@ def get_next(next_link=None): def _recover_initial( self, - location_name, # type: str - deleted_server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DeletedServer"] + location_name: str, + deleted_server_name: str, + **kwargs: Any + ) -> Optional["_models.DeletedServer"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeletedServer"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._recover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'deletedServerName': self._serialize.url("deleted_server_name", deleted_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_recover_request_initial( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + template_url=self._recover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -292,15 +404,17 @@ def _recover_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _recover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover'} # type: ignore + + @distributed_trace def begin_recover( self, - location_name, # type: str - deleted_server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DeletedServer"] + location_name: str, + deleted_server_name: str, + **kwargs: Any + ) -> LROPoller["_models.DeletedServer"]: """Recovers a deleted server. :param location_name: The name of the region where the resource is located. @@ -309,15 +423,18 @@ def begin_recover( :type deleted_server_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 DeletedServer or the result of cls(response) + :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 DeletedServer or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServer"] lro_delay = kwargs.pop( 'polling_interval', @@ -331,24 +448,17 @@ def begin_recover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeletedServer', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'deletedServerName': self._serialize.url("deleted_server_name", deleted_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -360,4 +470,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_recover.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py index 96fdae27c1097..429497c914248 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py @@ -5,23 +5,62 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_elastic_pool_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ElasticPoolActivitiesOperations(object): """ElasticPoolActivitiesOperations operations. @@ -45,14 +84,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_elastic_pool( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ElasticPoolActivityListResult"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> Iterable["_models.ElasticPoolActivityListResult"]: """Returns elastic pool activities. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -63,7 +102,8 @@ def list_by_elastic_pool( :param elastic_pool_name: The name of the elastic pool for which to get the current activity. :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolActivityListResult or the result of cls(response) + :return: An iterator like instance of either ElasticPoolActivityListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -72,37 +112,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolActivityListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolActivityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,6 +158,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py index 20cff79d1eb1e..03659a7b357e0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py @@ -5,23 +5,62 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_elastic_pool_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ElasticPoolDatabaseActivitiesOperations(object): """ElasticPoolDatabaseActivitiesOperations operations. @@ -45,14 +84,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_elastic_pool( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ElasticPoolDatabaseActivityListResult"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> Iterable["_models.ElasticPoolDatabaseActivityListResult"]: """Returns activity on databases inside of an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -63,8 +102,10 @@ def list_by_elastic_pool( :param elastic_pool_name: The name of the elastic pool. :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolDatabaseActivityListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivityListResult] + :return: An iterator like instance of either ElasticPoolDatabaseActivityListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPoolDatabaseActivityListResult"] @@ -72,37 +113,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolDatabaseActivityListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolDatabaseActivityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,6 +159,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_operations_operations.py index e3d1dda73dca4..b623eefb33bc3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_operations_operations.py @@ -5,23 +5,95 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_cancel_request( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_elastic_pool_request( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ElasticPoolOperationsOperations(object): """ElasticPoolOperationsOperations operations. @@ -45,15 +117,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def cancel( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + operation_id: str, + **kwargs: Any + ) -> None: """Cancels the asynchronous operation on the elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -75,27 +147,19 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,14 +172,15 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel'} # type: ignore + + @distributed_trace def list_by_elastic_pool( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ElasticPoolOperationListResult"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> Iterable["_models.ElasticPoolOperationListResult"]: """Gets a list of operations performed on the elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -126,7 +191,8 @@ def list_by_elastic_pool( :param elastic_pool_name: :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolOperationListResult or the result of cls(response) + :return: An iterator like instance of either ElasticPoolOperationListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -135,37 +201,35 @@ def list_by_elastic_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_elastic_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolOperationListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,6 +247,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py index 2b3e46d5791cd..fa5bc60d615ec 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py @@ -5,25 +5,335 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_metric_definitions_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_failover_request_initial( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) class ElasticPoolsOperations(object): """ElasticPoolsOperations operations. @@ -47,15 +357,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricListResult"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.MetricListResult"]: """Returns elastic pool metrics. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,38 +387,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,19 +435,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics'} # type: ignore + @distributed_trace def list_metric_definitions( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionListResult"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionListResult"]: """Returns elastic pool metric definitions. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -149,7 +459,8 @@ def list_metric_definitions( :param elastic_pool_name: The name of the elastic pool. :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionListResult or the result of cls(response) + :return: An iterator like instance of either MetricDefinitionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.MetricDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -158,37 +469,35 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricDefinitionListResult', pipeline_response) + deserialized = self._deserialize("MetricDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -206,19 +515,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metric_definitions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ElasticPoolListResult"] + resource_group_name: str, + server_name: str, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ElasticPoolListResult"]: """Gets all elastic pools in a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -229,7 +539,8 @@ def list_by_server( :param skip: The number of elements in the collection to skip. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ElasticPoolListResult or the result of cls(response) + :return: An iterator like instance of either ElasticPoolListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -238,38 +549,35 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip=skip, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip=skip, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ElasticPoolListResult', pipeline_response) + deserialized = self._deserialize("ElasticPoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -287,19 +595,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ElasticPool" + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> "_models.ElasticPool": """Gets an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -319,28 +628,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -354,49 +653,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - parameters, # type: "_models.ElasticPool" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ElasticPool"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: "_models.ElasticPool", + **kwargs: Any + ) -> Optional["_models.ElasticPool"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ElasticPool"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ElasticPool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ElasticPool') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -415,17 +705,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - parameters, # type: "_models.ElasticPool" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ElasticPool"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: "_models.ElasticPool", + **kwargs: Any + ) -> LROPoller["_models.ElasticPool"]: """Creates or updates an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -439,15 +731,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ElasticPool :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. + :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 ElasticPool or the result of cls(response) + :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 ElasticPool or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPool"] lro_delay = kwargs.pop( 'polling_interval', @@ -460,28 +756,21 @@ def begin_create_or_update( server_name=server_name, elastic_pool_name=elastic_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ElasticPool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -493,41 +782,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -540,14 +821,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -559,15 +841,17 @@ def begin_delete( :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -582,22 +866,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -609,49 +885,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - parameters, # type: "_models.ElasticPoolUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ElasticPool"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: "_models.ElasticPoolUpdate", + **kwargs: Any + ) -> Optional["_models.ElasticPool"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ElasticPool"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ElasticPoolUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ElasticPoolUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -667,17 +933,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - parameters, # type: "_models.ElasticPoolUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ElasticPool"] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: "_models.ElasticPoolUpdate", + **kwargs: Any + ) -> LROPoller["_models.ElasticPool"]: """Updates an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -691,15 +959,19 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate :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. + :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 ElasticPool or the result of cls(response) + :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 ElasticPool or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticPool"] lro_delay = kwargs.pop( 'polling_interval', @@ -712,28 +984,21 @@ def begin_update( server_name=server_name, elastic_pool_name=elastic_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ElasticPool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -745,41 +1010,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}'} # type: ignore def _failover_initial( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -792,14 +1049,15 @@ def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover'} # type: ignore + + @distributed_trace def begin_failover( self, - resource_group_name, # type: str - server_name, # type: str - elastic_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Failovers an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -811,15 +1069,17 @@ def begin_failover( :type elastic_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -834,22 +1094,14 @@ def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -861,4 +1113,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py index f3353a4ca5bdb..abfb4ebfe3995 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_revalidate_request_initial( + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) class EncryptionProtectorsOperations(object): """EncryptionProtectorsOperations operations. @@ -47,13 +199,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EncryptionProtectorListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.EncryptionProtectorListResult"]: """Gets a list of server encryption protectors. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -62,7 +214,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EncryptionProtectorListResult or the result of cls(response) + :return: An iterator like instance of either EncryptionProtectorListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.EncryptionProtectorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,36 +224,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EncryptionProtectorListResult', pipeline_response) + deserialized = self._deserialize("EncryptionProtectorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,19 +268,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.EncryptionProtector" + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + **kwargs: Any + ) -> "_models.EncryptionProtector": """Gets a server encryption protector. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -150,28 +301,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,49 +326,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - parameters, # type: "_models.EncryptionProtector" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.EncryptionProtector"] + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: "_models.EncryptionProtector", + **kwargs: Any + ) -> Optional["_models.EncryptionProtector"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.EncryptionProtector"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'EncryptionProtector') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'EncryptionProtector') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,17 +375,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - parameters, # type: "_models.EncryptionProtector" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.EncryptionProtector"] + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: "_models.EncryptionProtector", + **kwargs: Any + ) -> LROPoller["_models.EncryptionProtector"]: """Updates an existing encryption protector. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -267,15 +401,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.EncryptionProtector :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. + :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 EncryptionProtector or the result of cls(response) + :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 EncryptionProtector or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtector"] lro_delay = kwargs.pop( 'polling_interval', @@ -288,28 +426,21 @@ def begin_create_or_update( server_name=server_name, encryption_protector_name=encryption_protector_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('EncryptionProtector', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -321,41 +452,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore def _revalidate_initial( self, - resource_group_name, # type: str - server_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._revalidate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_revalidate_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self._revalidate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -368,14 +491,15 @@ def _revalidate_initial( _revalidate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore + + @distributed_trace def begin_revalidate( self, - resource_group_name, # type: str - server_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + **kwargs: Any + ) -> LROPoller[None]: """Revalidates an existing encryption protector. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -387,15 +511,17 @@ def begin_revalidate( :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,22 +536,14 @@ def begin_revalidate( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -437,4 +555,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_revalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py index bcedcb4f5039b..95e8080eae676 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py @@ -5,23 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ExtendedDatabaseBlobAuditingPoliciesOperations(object): """ExtendedDatabaseBlobAuditingPoliciesOperations operations. @@ -45,14 +172,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ExtendedDatabaseBlobAuditingPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.ExtendedDatabaseBlobAuditingPolicy": """Gets an extended database's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,30 +199,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,17 +224,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.ExtendedDatabaseBlobAuditingPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.ExtendedDatabaseBlobAuditingPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.ExtendedDatabaseBlobAuditingPolicy", + **kwargs: Any + ) -> "_models.ExtendedDatabaseBlobAuditingPolicy": """Creates or updates an extended database's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -141,35 +258,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExtendedDatabaseBlobAuditingPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExtendedDatabaseBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,16 +292,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ExtendedDatabaseBlobAuditingPolicyListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.ExtendedDatabaseBlobAuditingPolicyListResult"]: """Lists extended auditing settings of a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -207,8 +314,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedDatabaseBlobAuditingPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicyListResult] + :return: An iterator like instance of either ExtendedDatabaseBlobAuditingPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedDatabaseBlobAuditingPolicyListResult"] @@ -216,37 +325,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ExtendedDatabaseBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("ExtendedDatabaseBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -264,6 +371,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_server_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_server_blob_auditing_policies_operations.py index 2dc1c73087f40..ba02f34253611 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_server_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_server_blob_auditing_policies_operations.py @@ -5,25 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ExtendedServerBlobAuditingPoliciesOperations(object): """ExtendedServerBlobAuditingPoliciesOperations operations. @@ -47,13 +168,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ExtendedServerBlobAuditingPolicy" + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> "_models.ExtendedServerBlobAuditingPolicy": """Gets an extended server's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,29 +192,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,49 +216,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ExtendedServerBlobAuditingPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ExtendedServerBlobAuditingPolicy"] + resource_group_name: str, + server_name: str, + parameters: "_models.ExtendedServerBlobAuditingPolicy", + **kwargs: Any + ) -> Optional["_models.ExtendedServerBlobAuditingPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ExtendedServerBlobAuditingPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExtendedServerBlobAuditingPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExtendedServerBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,16 +263,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ExtendedServerBlobAuditingPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ExtendedServerBlobAuditingPolicy"] + resource_group_name: str, + server_name: str, + parameters: "_models.ExtendedServerBlobAuditingPolicy", + **kwargs: Any + ) -> LROPoller["_models.ExtendedServerBlobAuditingPolicy"]: """Creates or updates an extended server's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -186,15 +286,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy :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. + :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 ExtendedServerBlobAuditingPolicy or the result of cls(response) + :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 ExtendedServerBlobAuditingPolicy or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -206,29 +310,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ExtendedServerBlobAuditingPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - blob_auditing_policy_name = "default" - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -240,15 +336,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ExtendedServerBlobAuditingPolicyListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ExtendedServerBlobAuditingPolicyListResult"]: """Lists extended auditing settings of a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -257,8 +354,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedServerBlobAuditingPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicyListResult] + :return: An iterator like instance of either ExtendedServerBlobAuditingPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicyListResult"] @@ -266,36 +365,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ExtendedServerBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -313,6 +409,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_failover_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_failover_groups_operations.py index 352a92e232dce..de0e0648126c8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_failover_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_failover_groups_operations.py @@ -5,25 +5,297 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + failover_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + failover_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_failover_request_initial( + resource_group_name: str, + server_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_force_failover_allow_data_loss_request_initial( + resource_group_name: str, + server_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class FailoverGroupsOperations(object): """FailoverGroupsOperations operations. @@ -47,14 +319,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.FailoverGroup" + resource_group_name: str, + server_name: str, + failover_group_name: str, + **kwargs: Any + ) -> "_models.FailoverGroup": """Gets a failover group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +346,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +371,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - parameters, # type: "_models.FailoverGroup" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: "_models.FailoverGroup", + **kwargs: Any + ) -> Optional["_models.FailoverGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.FailoverGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'FailoverGroup') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FailoverGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +423,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - parameters, # type: "_models.FailoverGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: "_models.FailoverGroup", + **kwargs: Any + ) -> LROPoller["_models.FailoverGroup"]: """Creates or updates a failover group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -194,15 +449,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.FailoverGroup :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. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,28 +474,21 @@ def begin_create_or_update( server_name=server_name, failover_group_name=failover_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -248,41 +500,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + failover_group_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,14 +539,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + failover_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a failover group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -314,15 +559,17 @@ def begin_delete( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -337,22 +584,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -364,49 +603,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - parameters, # type: "_models.FailoverGroupUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: "_models.FailoverGroupUpdate", + **kwargs: Any + ) -> Optional["_models.FailoverGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.FailoverGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FailoverGroupUpdate') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FailoverGroupUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -422,17 +651,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - parameters, # type: "_models.FailoverGroupUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: "_models.FailoverGroupUpdate", + **kwargs: Any + ) -> LROPoller["_models.FailoverGroup"]: """Updates a failover group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -446,15 +677,19 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate :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. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -467,28 +702,21 @@ def begin_update( server_name=server_name, failover_group_name=failover_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -500,15 +728,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.FailoverGroupListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.FailoverGroupListResult"]: """Lists the failover groups in a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -517,7 +746,8 @@ def list_by_server( :param server_name: The name of the server containing the failover group. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FailoverGroupListResult or the result of cls(response) + :return: An iterator like instance of either FailoverGroupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FailoverGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -526,36 +756,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('FailoverGroupListResult', pipeline_response) + deserialized = self._deserialize("FailoverGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -573,6 +800,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -580,39 +808,28 @@ def get_next(next_link=None): def _failover_initial( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + **kwargs: Any + ) -> Optional["_models.FailoverGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.FailoverGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -628,16 +845,18 @@ def _failover_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover'} # type: ignore + + @distributed_trace def begin_failover( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + **kwargs: Any + ) -> LROPoller["_models.FailoverGroup"]: """Fails over from the current primary server to this server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -649,15 +868,18 @@ def begin_failover( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -672,25 +894,17 @@ def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -702,43 +916,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover'} # type: ignore def _force_failover_allow_data_loss_initial( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + **kwargs: Any + ) -> Optional["_models.FailoverGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.FailoverGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._force_failover_allow_data_loss_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_force_failover_allow_data_loss_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._force_failover_allow_data_loss_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -754,16 +958,18 @@ def _force_failover_allow_data_loss_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _force_failover_allow_data_loss_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore + + @distributed_trace def begin_force_failover_allow_data_loss( self, - resource_group_name, # type: str - server_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.FailoverGroup"] + resource_group_name: str, + server_name: str, + failover_group_name: str, + **kwargs: Any + ) -> LROPoller["_models.FailoverGroup"]: """Fails over from the current primary server to this server. This operation might result in data loss. @@ -776,15 +982,18 @@ def begin_force_failover_allow_data_loss( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 FailoverGroup or the result of cls(response) + :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 FailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.FailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -799,25 +1008,17 @@ def begin_force_failover_allow_data_loss( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('FailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -829,4 +1030,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_force_failover_allow_data_loss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py index 1ae85cec55eff..a9e168b3d4e76 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py @@ -5,23 +5,219 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_replace_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class FirewallRulesOperations(object): """FirewallRulesOperations operations. @@ -45,14 +241,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - firewall_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.FirewallRule" + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> "_models.FirewallRule": """Gets a firewall rule. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,28 +268,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,17 +293,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - firewall_rule_name, # type: str - parameters, # type: "_models.FirewallRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.FirewallRule" + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: "_models.FirewallRule", + **kwargs: Any + ) -> "_models.FirewallRule": """Creates or updates a firewall rule. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -139,33 +327,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FirewallRule') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FirewallRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,16 +361,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - firewall_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a firewall rule. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -212,26 +392,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -244,13 +416,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.FirewallRuleListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.FirewallRuleListResult"]: """Gets a list of firewall rules. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -259,7 +432,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FirewallRuleListResult or the result of cls(response) + :return: An iterator like instance of either FirewallRuleListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FirewallRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -268,36 +442,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('FirewallRuleListResult', pipeline_response) + deserialized = self._deserialize("FirewallRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -315,19 +486,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules'} # type: ignore + @distributed_trace def replace( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.FirewallRuleList" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.FirewallRule"] + resource_group_name: str, + server_name: str, + parameters: "_models.FirewallRuleList", + **kwargs: Any + ) -> Optional["_models.FirewallRule"]: """Replaces all firewall rules on the server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -347,32 +519,22 @@ def replace( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.replace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FirewallRuleList') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_replace_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.replace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FirewallRuleList') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -388,4 +550,6 @@ def replace( return cls(pipeline_response, deserialized, {}) return deserialized + replace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py index 2f7c56f6770d2..906b1b737040a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py @@ -5,23 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_database_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GeoBackupPoliciesOperations(object): """GeoBackupPoliciesOperations operations. @@ -45,16 +172,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - geo_backup_policy_name, # type: Union[str, "_models.GeoBackupPolicyName"] - parameters, # type: "_models.GeoBackupPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.GeoBackupPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + parameters: "_models.GeoBackupPolicy", + **kwargs: Any + ) -> "_models.GeoBackupPolicy": """Updates a database geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -78,34 +205,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'geoBackupPolicyName': self._serialize.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GeoBackupPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + geo_backup_policy_name=geo_backup_policy_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GeoBackupPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -123,17 +240,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - geo_backup_policy_name, # type: Union[str, "_models.GeoBackupPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.GeoBackupPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + **kwargs: Any + ) -> "_models.GeoBackupPolicy": """Gets a geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -155,29 +274,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'geoBackupPolicyName': self._serialize.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + geo_backup_policy_name=geo_backup_policy_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,16 +300,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GeoBackupPolicyListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.GeoBackupPolicyListResult"]: """Returns a list of geo backup policies. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -211,7 +322,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GeoBackupPolicyListResult or the result of cls(response) + :return: An iterator like instance of either GeoBackupPolicyListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.GeoBackupPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -220,37 +332,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GeoBackupPolicyListResult', pipeline_response) + deserialized = self._deserialize("GeoBackupPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -268,6 +378,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_failover_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_failover_groups_operations.py index 574fc05fef2f4..a23d4cd000d53 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_failover_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_failover_groups_operations.py @@ -5,25 +5,251 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + location_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + location_name: str, + failover_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + location_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_location_request( + resource_group_name: str, + location_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_failover_request_initial( + resource_group_name: str, + location_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_force_failover_allow_data_loss_request_initial( + resource_group_name: str, + location_name: str, + failover_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class InstanceFailoverGroupsOperations(object): """InstanceFailoverGroupsOperations operations. @@ -47,14 +273,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.InstanceFailoverGroup" + resource_group_name: str, + location_name: str, + failover_group_name: str, + **kwargs: Any + ) -> "_models.InstanceFailoverGroup": """Gets a failover group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +300,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +325,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - parameters, # type: "_models.InstanceFailoverGroup" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.InstanceFailoverGroup"] + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: "_models.InstanceFailoverGroup", + **kwargs: Any + ) -> Optional["_models.InstanceFailoverGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InstanceFailoverGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InstanceFailoverGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InstanceFailoverGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +377,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - parameters, # type: "_models.InstanceFailoverGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.InstanceFailoverGroup"] + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: "_models.InstanceFailoverGroup", + **kwargs: Any + ) -> LROPoller["_models.InstanceFailoverGroup"]: """Creates or updates a failover group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -194,15 +403,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup :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. + :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 InstanceFailoverGroup or the result of cls(response) + :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 InstanceFailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceFailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,28 +428,21 @@ def begin_create_or_update( location_name=location_name, failover_group_name=failover_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstanceFailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -248,41 +454,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + location_name: str, + failover_group_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,14 +493,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + location_name: str, + failover_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a failover group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -314,15 +513,17 @@ def begin_delete( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -337,22 +538,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -364,15 +557,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}'} # type: ignore + @distributed_trace def list_by_location( self, - resource_group_name, # type: str - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InstanceFailoverGroupListResult"] + resource_group_name: str, + location_name: str, + **kwargs: Any + ) -> Iterable["_models.InstanceFailoverGroupListResult"]: """Lists the failover groups in a location. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -381,7 +575,8 @@ def list_by_location( :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstanceFailoverGroupListResult or the result of cls(response) + :return: An iterator like instance of either InstanceFailoverGroupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstanceFailoverGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -390,36 +585,33 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InstanceFailoverGroupListResult', pipeline_response) + deserialized = self._deserialize("InstanceFailoverGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,6 +629,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -444,39 +637,28 @@ def get_next(next_link=None): def _failover_initial( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.InstanceFailoverGroup"] + resource_group_name: str, + location_name: str, + failover_group_name: str, + **kwargs: Any + ) -> Optional["_models.InstanceFailoverGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InstanceFailoverGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -492,16 +674,18 @@ def _failover_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover'} # type: ignore + + @distributed_trace def begin_failover( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.InstanceFailoverGroup"] + resource_group_name: str, + location_name: str, + failover_group_name: str, + **kwargs: Any + ) -> LROPoller["_models.InstanceFailoverGroup"]: """Fails over from the current primary managed instance to this managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -513,15 +697,18 @@ def begin_failover( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 InstanceFailoverGroup or the result of cls(response) + :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 InstanceFailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceFailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -536,25 +723,17 @@ def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstanceFailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -566,43 +745,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover'} # type: ignore def _force_failover_allow_data_loss_initial( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.InstanceFailoverGroup"] + resource_group_name: str, + location_name: str, + failover_group_name: str, + **kwargs: Any + ) -> Optional["_models.InstanceFailoverGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InstanceFailoverGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._force_failover_allow_data_loss_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_force_failover_allow_data_loss_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + template_url=self._force_failover_allow_data_loss_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -618,16 +787,18 @@ def _force_failover_allow_data_loss_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _force_failover_allow_data_loss_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore + + @distributed_trace def begin_force_failover_allow_data_loss( self, - resource_group_name, # type: str - location_name, # type: str - failover_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.InstanceFailoverGroup"] + resource_group_name: str, + location_name: str, + failover_group_name: str, + **kwargs: Any + ) -> LROPoller["_models.InstanceFailoverGroup"]: """Fails over from the current primary managed instance to this managed instance. This operation might result in data loss. @@ -640,15 +811,18 @@ def begin_force_failover_allow_data_loss( :type failover_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 InstanceFailoverGroup or the result of cls(response) + :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 InstanceFailoverGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceFailoverGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -663,25 +837,17 @@ def begin_force_failover_allow_data_loss( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstanceFailoverGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -693,4 +859,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_force_failover_allow_data_loss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py index 5f5ab25256fb4..eee6a5453f974 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py @@ -5,25 +5,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class InstancePoolsOperations(object): """InstancePoolsOperations operations. @@ -47,13 +266,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - instance_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.InstancePool" + resource_group_name: str, + instance_pool_name: str, + **kwargs: Any + ) -> "_models.InstancePool": """Gets an instance pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,27 +290,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,47 +314,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - instance_pool_name, # type: str - parameters, # type: "_models.InstancePool" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.InstancePool"] + resource_group_name: str, + instance_pool_name: str, + parameters: "_models.InstancePool", + **kwargs: Any + ) -> Optional["_models.InstancePool"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InstancePool"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InstancePool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InstancePool') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,16 +364,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - instance_pool_name, # type: str - parameters, # type: "_models.InstancePool" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.InstancePool"] + resource_group_name: str, + instance_pool_name: str, + parameters: "_models.InstancePool", + **kwargs: Any + ) -> LROPoller["_models.InstancePool"]: """Creates or updates an instance pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -185,15 +387,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.InstancePool :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. + :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 InstancePool or the result of cls(response) + :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 InstancePool or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstancePool"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,27 +411,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, instance_pool_name=instance_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstancePool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -237,39 +437,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - instance_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + instance_pool_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -282,13 +474,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - instance_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + instance_pool_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an instance pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -298,15 +491,17 @@ def begin_delete( :type instance_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -320,21 +515,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -346,47 +534,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - instance_pool_name, # type: str - parameters, # type: "_models.InstancePoolUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.InstancePool"] + resource_group_name: str, + instance_pool_name: str, + parameters: "_models.InstancePoolUpdate", + **kwargs: Any + ) -> Optional["_models.InstancePool"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InstancePool"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InstancePoolUpdate') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InstancePoolUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -402,16 +580,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - instance_pool_name, # type: str - parameters, # type: "_models.InstancePoolUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.InstancePool"] + resource_group_name: str, + instance_pool_name: str, + parameters: "_models.InstancePoolUpdate", + **kwargs: Any + ) -> LROPoller["_models.InstancePool"]: """Updates an instance pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -423,15 +603,19 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate :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. + :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 InstancePool or the result of cls(response) + :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 InstancePool or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InstancePool"] lro_delay = kwargs.pop( 'polling_interval', @@ -443,27 +627,21 @@ def begin_update( resource_group_name=resource_group_name, instance_pool_name=instance_pool_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InstancePool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -475,21 +653,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InstancePoolListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.InstancePoolListResult"]: """Gets a list of instance pools in the resource group. :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstancePoolListResult or the result of cls(response) + :return: An iterator like instance of either InstancePoolListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePoolListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -498,35 +678,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InstancePoolListResult', pipeline_response) + deserialized = self._deserialize("InstancePoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -544,20 +720,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InstancePoolListResult"] + **kwargs: Any + ) -> Iterable["_models.InstancePoolListResult"]: """Gets a list of all instance pools in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstancePoolListResult or the result of cls(response) + :return: An iterator like instance of either InstancePoolListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePoolListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -566,34 +744,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InstancePoolListResult', pipeline_response) + deserialized = self._deserialize("InstancePoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -611,6 +784,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ipv6_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ipv6_firewall_rules_operations.py new file mode 100644 index 0000000000000..821f73d633648 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ipv6_firewall_rules_operations.py @@ -0,0 +1,449 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class IPv6FirewallRulesOperations(object): + """IPv6FirewallRulesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sql.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> "_models.IPv6FirewallRule": + """Gets an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IPv6FirewallRule, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.IPv6FirewallRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + 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('IPv6FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: "_models.IPv6FirewallRule", + **kwargs: Any + ) -> "_models.IPv6FirewallRule": + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating an IPv6 firewall rule. + :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IPv6FirewallRule, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.IPv6FirewallRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IPv6FirewallRule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + 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('IPv6FirewallRule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('IPv6FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def list_by_server( + self, + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.IPv6FirewallRuleListResult"]: + """Gets a list of IPv6 firewall rules. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IPv6FirewallRuleListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.IPv6FirewallRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.IPv6FirewallRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IPv6FirewallRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py index 8cc2291f1ca18..d4b9f0bdec25b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py @@ -5,25 +5,223 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class JobAgentsOperations(object): """JobAgentsOperations operations. @@ -47,13 +245,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobAgentListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.JobAgentListResult"]: """Gets a list of job agents in a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,36 +269,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobAgentListResult', pipeline_response) + deserialized = self._deserialize("JobAgentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,19 +313,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobAgent" + resource_group_name: str, + server_name: str, + job_agent_name: str, + **kwargs: Any + ) -> "_models.JobAgent": """Gets a job agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -150,28 +346,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,49 +371,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - parameters, # type: "_models.JobAgent" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.JobAgent"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: "_models.JobAgent", + **kwargs: Any + ) -> Optional["_models.JobAgent"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.JobAgent"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'JobAgent') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobAgent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,17 +423,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - parameters, # type: "_models.JobAgent" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.JobAgent"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: "_models.JobAgent", + **kwargs: Any + ) -> LROPoller["_models.JobAgent"]: """Creates or updates a job agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -270,15 +449,18 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.JobAgent :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. + :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. + :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 JobAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -291,28 +473,21 @@ def begin_create_or_update( server_name=server_name, job_agent_name=job_agent_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -324,41 +499,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + job_agent_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -371,14 +538,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + job_agent_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a job agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -390,15 +558,17 @@ def begin_delete( :type job_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -413,22 +583,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -440,49 +602,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - parameters, # type: "_models.JobAgentUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.JobAgent"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: "_models.JobAgentUpdate", + **kwargs: Any + ) -> Optional["_models.JobAgent"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.JobAgent"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'JobAgentUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobAgentUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -498,17 +650,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - parameters, # type: "_models.JobAgentUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.JobAgent"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: "_models.JobAgentUpdate", + **kwargs: Any + ) -> LROPoller["_models.JobAgent"]: """Updates a job agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -522,15 +676,18 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate :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. + :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. + :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 JobAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -543,28 +700,21 @@ def begin_update( server_name=server_name, job_agent_name=job_agent_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -576,4 +726,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py index 8e7c17b51f003..c085ee1ed5d43 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py @@ -5,23 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_agent_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class JobCredentialsOperations(object): """JobCredentialsOperations operations. @@ -45,14 +205,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobCredentialListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + **kwargs: Any + ) -> Iterable["_models.JobCredentialListResult"]: """Gets a list of jobs credentials. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -63,7 +223,8 @@ def list_by_agent( :param job_agent_name: The name of the job agent. :type job_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobCredentialListResult or the result of cls(response) + :return: An iterator like instance of either JobCredentialListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobCredentialListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -72,37 +233,35 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobCredentialListResult', pipeline_response) + deserialized = self._deserialize("JobCredentialListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,20 +279,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - credential_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobCredential" + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + **kwargs: Any + ) -> "_models.JobCredential": """Gets a jobs credential. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -155,29 +315,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,18 +341,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - credential_name, # type: str - parameters, # type: "_models.JobCredential" - **kwargs # type: Any - ): - # type: (...) -> "_models.JobCredential" + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: "_models.JobCredential", + **kwargs: Any + ) -> "_models.JobCredential": """Creates or updates a job credential. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -226,34 +378,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'JobCredential') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -271,17 +413,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - credential_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + **kwargs: Any + ) -> None: """Deletes a job credential. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -303,27 +447,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -335,3 +471,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py index a8b75e38e1a81..aa871c1f9d6e9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py @@ -6,25 +6,303 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_agent_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if create_time_min is not None: + query_parameters['createTimeMin'] = _SERIALIZER.query("create_time_min", create_time_min, 'iso-8601') + if create_time_max is not None: + query_parameters['createTimeMax'] = _SERIALIZER.query("create_time_max", create_time_max, 'iso-8601') + if end_time_min is not None: + query_parameters['endTimeMin'] = _SERIALIZER.query("end_time_min", end_time_min, 'iso-8601') + if end_time_max is not None: + query_parameters['endTimeMax'] = _SERIALIZER.query("end_time_max", end_time_max, 'iso-8601') + if is_active is not None: + query_parameters['isActive'] = _SERIALIZER.query("is_active", is_active, 'bool') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_cancel_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_request_initial( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_job_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if create_time_min is not None: + query_parameters['createTimeMin'] = _SERIALIZER.query("create_time_min", create_time_min, 'iso-8601') + if create_time_max is not None: + query_parameters['createTimeMax'] = _SERIALIZER.query("create_time_max", create_time_max, 'iso-8601') + if end_time_min is not None: + query_parameters['endTimeMin'] = _SERIALIZER.query("end_time_min", end_time_min, 'iso-8601') + if end_time_max is not None: + query_parameters['endTimeMax'] = _SERIALIZER.query("end_time_max", end_time_max, 'iso-8601') + if is_active is not None: + query_parameters['isActive'] = _SERIALIZER.query("is_active", is_active, 'bool') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobExecutionsOperations(object): """JobExecutionsOperations operations. @@ -48,21 +326,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - create_time_min=None, # type: Optional[datetime.datetime] - create_time_max=None, # type: Optional[datetime.datetime] - end_time_min=None, # type: Optional[datetime.datetime] - end_time_max=None, # type: Optional[datetime.datetime] - is_active=None, # type: Optional[bool] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobExecutionListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.JobExecutionListResult"]: """Lists all executions in a job agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -91,7 +369,8 @@ def list_by_agent( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -100,51 +379,49 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -162,21 +439,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions'} # type: ignore + @distributed_trace def cancel( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> None: """Requests cancellation of a job execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -200,28 +478,20 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,43 +504,33 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel'} # type: ignore + def _create_initial( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.JobExecution"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + **kwargs: Any + ) -> Optional["_models.JobExecution"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.JobExecution"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -286,17 +546,19 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.JobExecution"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + **kwargs: Any + ) -> LROPoller["_models.JobExecution"]: """Starts an elastic job execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -310,15 +572,18 @@ def begin_create( :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 JobExecution or the result of cls(response) + :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 JobExecution or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobExecution"] lro_delay = kwargs.pop( 'polling_interval', @@ -334,26 +599,17 @@ def begin_create( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobExecution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -365,24 +621,25 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start'} # type: ignore + @distributed_trace def list_by_job( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - create_time_min=None, # type: Optional[datetime.datetime] - create_time_max=None, # type: Optional[datetime.datetime] - end_time_min=None, # type: Optional[datetime.datetime] - end_time_max=None, # type: Optional[datetime.datetime] - is_active=None, # type: Optional[bool] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobExecutionListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.JobExecutionListResult"]: """Lists a job's executions. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -413,7 +670,8 @@ def list_by_job( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -422,52 +680,51 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -485,21 +742,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobExecution" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> "_models.JobExecution": """Gets a job execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -523,30 +781,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -560,47 +808,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.JobExecution"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> Optional["_models.JobExecution"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.JobExecution"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -619,18 +858,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.JobExecution"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> LROPoller["_models.JobExecution"]: """Creates or updates a job execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -646,15 +887,18 @@ def begin_create_or_update( :type job_execution_id: 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. + :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 JobExecution or the result of cls(response) + :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 JobExecution or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.JobExecution"] lro_delay = kwargs.pop( 'polling_interval', @@ -671,27 +915,17 @@ def begin_create_or_update( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('JobExecution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -703,4 +937,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py index f12f87bf0ad2d..f32626e41460a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py @@ -6,23 +6,131 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_job_execution_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if create_time_min is not None: + query_parameters['createTimeMin'] = _SERIALIZER.query("create_time_min", create_time_min, 'iso-8601') + if create_time_max is not None: + query_parameters['createTimeMax'] = _SERIALIZER.query("create_time_max", create_time_max, 'iso-8601') + if end_time_min is not None: + query_parameters['endTimeMin'] = _SERIALIZER.query("end_time_min", end_time_min, 'iso-8601') + if end_time_max is not None: + query_parameters['endTimeMax'] = _SERIALIZER.query("end_time_max", end_time_max, 'iso-8601') + if is_active is not None: + query_parameters['isActive'] = _SERIALIZER.query("is_active", is_active, 'bool') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobStepExecutionsOperations(object): """JobStepExecutionsOperations operations. @@ -46,23 +154,23 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_job_execution( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - create_time_min=None, # type: Optional[datetime.datetime] - create_time_max=None, # type: Optional[datetime.datetime] - end_time_min=None, # type: Optional[datetime.datetime] - end_time_max=None, # type: Optional[datetime.datetime] - is_active=None, # type: Optional[bool] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobExecutionListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.JobExecutionListResult"]: """Lists the step executions of a job execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -95,7 +203,8 @@ def list_by_job_execution( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -104,53 +213,53 @@ def list_by_job_execution( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job_execution.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_job_execution.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,22 +277,23 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_job_execution.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - step_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobExecution" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + **kwargs: Any + ) -> "_models.JobExecution": """Gets a step execution of a job execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -209,31 +319,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -247,4 +347,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py index e1deb09156ac5..785da48cd9fb0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py @@ -5,23 +5,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_version_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobVersion": _SERIALIZER.url("job_version", job_version, 'int'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_version_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobVersion": _SERIALIZER.url("job_version", job_version, 'int'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_job_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class JobStepsOperations(object): """JobStepsOperations operations. @@ -45,16 +297,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_version( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_version, # type: int - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobStepListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + **kwargs: Any + ) -> Iterable["_models.JobStepListResult"]: """Gets all job steps in the specified job version. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -78,39 +330,39 @@ def list_by_version( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_version.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobVersion': self._serialize.url("job_version", job_version, 'int'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_version_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + template_url=self.list_by_version.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_version_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobStepListResult', pipeline_response) + deserialized = self._deserialize("JobStepListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,22 +380,23 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_version.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps'} # type: ignore + @distributed_trace def get_by_version( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_version, # type: int - step_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStep" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + step_name: str, + **kwargs: Any + ) -> "_models.JobStep": """Gets the specified version of a job step. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -169,31 +422,21 @@ def get_by_version( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_version.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobVersion': self._serialize.url("job_version", job_version, 'int'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_version_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_version.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,17 +450,19 @@ def get_by_version( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_version.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}'} # type: ignore + + @distributed_trace def list_by_job( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobStepListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + **kwargs: Any + ) -> Iterable["_models.JobStepListResult"]: """Gets all job steps for a job's current version. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -239,38 +484,37 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobStepListResult', pipeline_response) + deserialized = self._deserialize("JobStepListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -288,21 +532,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - step_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStep" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + **kwargs: Any + ) -> "_models.JobStep": """Gets a job step in a job's current version. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -326,30 +571,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -363,19 +598,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - step_name, # type: str - parameters, # type: "_models.JobStep" - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStep" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: "_models.JobStep", + **kwargs: Any + ) -> "_models.JobStep": """Creates or updates a job step. This will implicitly create a new job version. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -401,35 +638,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'JobStep') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobStep') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -447,18 +674,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - step_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + **kwargs: Any + ) -> None: """Deletes a job step. This will implicitly create a new job version. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -482,28 +711,20 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -515,3 +736,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py index b2ae758935335..650a07c930ca5 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py @@ -6,23 +6,198 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_job_execution_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if create_time_min is not None: + query_parameters['createTimeMin'] = _SERIALIZER.query("create_time_min", create_time_min, 'iso-8601') + if create_time_max is not None: + query_parameters['createTimeMax'] = _SERIALIZER.query("create_time_max", create_time_max, 'iso-8601') + if end_time_min is not None: + query_parameters['endTimeMin'] = _SERIALIZER.query("end_time_min", end_time_min, 'iso-8601') + if end_time_max is not None: + query_parameters['endTimeMax'] = _SERIALIZER.query("end_time_max", end_time_max, 'iso-8601') + if is_active is not None: + query_parameters['isActive'] = _SERIALIZER.query("is_active", is_active, 'bool') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_step_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if create_time_min is not None: + query_parameters['createTimeMin'] = _SERIALIZER.query("create_time_min", create_time_min, 'iso-8601') + if create_time_max is not None: + query_parameters['createTimeMax'] = _SERIALIZER.query("create_time_max", create_time_max, 'iso-8601') + if end_time_min is not None: + query_parameters['endTimeMin'] = _SERIALIZER.query("end_time_min", end_time_min, 'iso-8601') + if end_time_max is not None: + query_parameters['endTimeMax'] = _SERIALIZER.query("end_time_max", end_time_max, 'iso-8601') + if is_active is not None: + query_parameters['isActive'] = _SERIALIZER.query("is_active", is_active, 'bool') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + target_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, 'str'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + "targetId": _SERIALIZER.url("target_id", target_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobTargetExecutionsOperations(object): """JobTargetExecutionsOperations operations. @@ -46,23 +221,23 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_job_execution( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - create_time_min=None, # type: Optional[datetime.datetime] - create_time_max=None, # type: Optional[datetime.datetime] - end_time_min=None, # type: Optional[datetime.datetime] - end_time_max=None, # type: Optional[datetime.datetime] - is_active=None, # type: Optional[bool] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobExecutionListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.JobExecutionListResult"]: """Lists target executions for all steps of a job execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -95,7 +270,8 @@ def list_by_job_execution( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -104,53 +280,53 @@ def list_by_job_execution( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job_execution.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_job_execution.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,29 +344,30 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_job_execution.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets'} # type: ignore + @distributed_trace def list_by_step( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - step_name, # type: str - create_time_min=None, # type: Optional[datetime.datetime] - create_time_max=None, # type: Optional[datetime.datetime] - end_time_min=None, # type: Optional[datetime.datetime] - end_time_max=None, # type: Optional[datetime.datetime] - is_active=None, # type: Optional[bool] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobExecutionListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.JobExecutionListResult"]: """Lists the target executions of a job step execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -225,7 +402,8 @@ def list_by_step( :param top: The number of elements to return from the collection. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobExecutionListResult or the result of cls(response) + :return: An iterator like instance of either JobExecutionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecutionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -234,54 +412,55 @@ def list_by_step( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_step.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if create_time_min is not None: - query_parameters['createTimeMin'] = self._serialize.query("create_time_min", create_time_min, 'iso-8601') - if create_time_max is not None: - query_parameters['createTimeMax'] = self._serialize.query("create_time_max", create_time_max, 'iso-8601') - if end_time_min is not None: - query_parameters['endTimeMin'] = self._serialize.query("end_time_min", end_time_min, 'iso-8601') - if end_time_max is not None: - query_parameters['endTimeMax'] = self._serialize.query("end_time_max", end_time_max, 'iso-8601') - if is_active is not None: - query_parameters['isActive'] = self._serialize.query("is_active", is_active, 'bool') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_step_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=self.list_by_step.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_step_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobExecutionListResult', pipeline_response) + deserialized = self._deserialize("JobExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -299,23 +478,24 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_step.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_execution_id, # type: str - step_name, # type: str - target_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobExecution" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + target_id: str, + **kwargs: Any + ) -> "_models.JobExecution": """Gets a target execution. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -343,32 +523,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobExecutionId': self._serialize.url("job_execution_id", job_execution_id, 'str'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - 'targetId': self._serialize.url("target_id", target_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + target_id=target_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -382,4 +552,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py index 838ae59be35c3..d7e7b9cd40972 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py @@ -5,23 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_agent_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class JobTargetGroupsOperations(object): """JobTargetGroupsOperations operations. @@ -45,14 +205,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobTargetGroupListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + **kwargs: Any + ) -> Iterable["_models.JobTargetGroupListResult"]: """Gets all target groups in an agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -63,7 +223,8 @@ def list_by_agent( :param job_agent_name: The name of the job agent. :type job_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobTargetGroupListResult or the result of cls(response) + :return: An iterator like instance of either JobTargetGroupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobTargetGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -72,37 +233,35 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobTargetGroupListResult', pipeline_response) + deserialized = self._deserialize("JobTargetGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,20 +279,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - target_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobTargetGroup" + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + **kwargs: Any + ) -> "_models.JobTargetGroup": """Gets a target group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -155,29 +315,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'targetGroupName': self._serialize.url("target_group_name", target_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,18 +341,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - target_group_name, # type: str - parameters, # type: "_models.JobTargetGroup" - **kwargs # type: Any - ): - # type: (...) -> "_models.JobTargetGroup" + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: "_models.JobTargetGroup", + **kwargs: Any + ) -> "_models.JobTargetGroup": """Creates or updates a target group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -226,34 +378,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'targetGroupName': self._serialize.url("target_group_name", target_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'JobTargetGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobTargetGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -271,17 +413,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - target_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + **kwargs: Any + ) -> None: """Deletes a target group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -303,27 +447,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'targetGroupName': self._serialize.url("target_group_name", target_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -335,3 +471,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py index 6726baf55b7bc..8d9e43ea4a6fd 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py @@ -5,23 +5,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_job_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobVersion": _SERIALIZER.url("job_version", job_version, 'int'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobVersionsOperations(object): """JobVersionsOperations operations. @@ -45,15 +127,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_job( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobVersionListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + **kwargs: Any + ) -> Iterable["_models.JobVersionListResult"]: """Gets all versions of a job. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -66,7 +148,8 @@ def list_by_job( :param job_name: The name of the job to get. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobVersionListResult or the result of cls(response) + :return: An iterator like instance of either JobVersionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobVersionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -75,38 +158,37 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobVersionListResult', pipeline_response) + deserialized = self._deserialize("JobVersionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,21 +206,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - job_version, # type: int - **kwargs # type: Any - ): - # type: (...) -> "_models.JobVersion" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + **kwargs: Any + ) -> "_models.JobVersion": """Gets a job version. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -162,30 +245,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobVersion': self._serialize.url("job_version", job_version, 'int'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -199,4 +272,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py index f767ed3ce059c..5003634f16398 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py @@ -5,23 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_agent_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class JobsOperations(object): """JobsOperations operations. @@ -45,14 +205,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_agent( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobListResult"] + resource_group_name: str, + server_name: str, + job_agent_name: str, + **kwargs: Any + ) -> Iterable["_models.JobListResult"]: """Gets a list of jobs. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,37 +232,35 @@ def list_by_agent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_agent.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_agent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobListResult', pipeline_response) + deserialized = self._deserialize("JobListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,20 +278,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_agent.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + **kwargs: Any + ) -> "_models.Job": """Gets a job. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -155,29 +314,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,18 +340,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - parameters, # type: "_models.Job" - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: "_models.Job", + **kwargs: Any + ) -> "_models.Job": """Creates or updates a job. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -226,34 +377,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Job') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Job') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -271,17 +412,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - job_agent_name, # type: str - job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + **kwargs: Any + ) -> None: """Deletes a job. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -303,27 +446,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'jobAgentName': self._serialize.url("job_agent_name", job_agent_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -335,3 +470,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py index 3f74b2164b244..3acb2cf0a1e36 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py @@ -5,25 +5,191 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_disable_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LedgerDigestUploadsOperations(object): """LedgerDigestUploadsOperations operations. @@ -47,15 +213,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - ledger_digest_uploads, # type: Union[str, "_models.LedgerDigestUploadsName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.LedgerDigestUploads" + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + **kwargs: Any + ) -> "_models.LedgerDigestUploads": """Gets the current ledger digest upload configuration for a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,29 +243,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,51 +269,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - ledger_digest_uploads, # type: Union[str, "_models.LedgerDigestUploadsName"] - parameters, # type: "_models.LedgerDigestUploads" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LedgerDigestUploads"] + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + parameters: "_models.LedgerDigestUploads", + **kwargs: Any + ) -> Optional["_models.LedgerDigestUploads"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LedgerDigestUploads"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'LedgerDigestUploads') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LedgerDigestUploads') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,18 +320,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - ledger_digest_uploads, # type: Union[str, "_models.LedgerDigestUploadsName"] - parameters, # type: "_models.LedgerDigestUploads" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LedgerDigestUploads"] + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + parameters: "_models.LedgerDigestUploads", + **kwargs: Any + ) -> LROPoller["_models.LedgerDigestUploads"]: """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger instance. @@ -201,15 +350,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] lro_delay = kwargs.pop( 'polling_interval', @@ -223,29 +376,21 @@ def begin_create_or_update( database_name=database_name, ledger_digest_uploads=ledger_digest_uploads, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -257,16 +402,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LedgerDigestUploadsListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.LedgerDigestUploadsListResult"]: """Gets all ledger digest upload settings on a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -277,7 +423,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LedgerDigestUploadsListResult or the result of cls(response) + :return: An iterator like instance of either LedgerDigestUploadsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LedgerDigestUploadsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -286,37 +433,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LedgerDigestUploadsListResult', pipeline_response) + deserialized = self._deserialize("LedgerDigestUploadsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -334,6 +479,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -341,41 +487,30 @@ def get_next(next_link=None): def _disable_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - ledger_digest_uploads, # type: Union[str, "_models.LedgerDigestUploadsName"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LedgerDigestUploads"] + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + **kwargs: Any + ) -> Optional["_models.LedgerDigestUploads"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LedgerDigestUploads"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._disable_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_disable_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + template_url=self._disable_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -391,17 +526,19 @@ def _disable_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _disable_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore + + @distributed_trace def begin_disable( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - ledger_digest_uploads, # type: Union[str, "_models.LedgerDigestUploadsName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LedgerDigestUploads"] + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + **kwargs: Any + ) -> LROPoller["_models.LedgerDigestUploads"]: """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger instance. @@ -416,15 +553,18 @@ def begin_disable( :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] lro_delay = kwargs.pop( 'polling_interval', @@ -440,26 +580,17 @@ def begin_disable( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -471,4 +602,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py index dba1d2b19ac00..fe7fe13b95bcf 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py @@ -5,25 +5,630 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_copy_request_initial( + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_database_request( + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_location_request( + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_request( + location_name: str, + long_term_retention_server_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_copy_by_resource_group_request_initial( + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_by_resource_group_request_initial( + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_resource_group_request( + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_resource_group_request_initial( + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_resource_group_database_request( + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "longTermRetentionDatabaseName": _SERIALIZER.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_location_request( + resource_group_name: str, + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_server_request( + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "longTermRetentionServerName": _SERIALIZER.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LongTermRetentionBackupsOperations(object): """LongTermRetentionBackupsOperations operations. @@ -49,47 +654,36 @@ def __init__(self, client, config, serializer, deserializer): def _copy_initial( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.CopyLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LongTermRetentionBackupOperationResult"] + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.CopyLongTermRetentionBackupParameters", + **kwargs: Any + ) -> Optional["_models.LongTermRetentionBackupOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LongTermRetentionBackupOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._copy_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') + + request = build_copy_request_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._copy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,18 +699,20 @@ def _copy_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _copy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore + + @distributed_trace def begin_copy( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.CopyLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LongTermRetentionBackupOperationResult"] + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.CopyLongTermRetentionBackupParameters", + **kwargs: Any + ) -> LROPoller["_models.LongTermRetentionBackupOperationResult"]: """Copy an existing long term retention backup. :param location_name: The location of the database. @@ -131,15 +727,20 @@ def begin_copy( :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -153,29 +754,21 @@ def begin_copy( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -187,51 +780,41 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_copy.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore def _update_initial( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.UpdateLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LongTermRetentionBackupOperationResult"] + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.UpdateLongTermRetentionBackupParameters", + **kwargs: Any + ) -> Optional["_models.LongTermRetentionBackupOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LongTermRetentionBackupOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -247,18 +830,20 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + + @distributed_trace def begin_update( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.UpdateLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LongTermRetentionBackupOperationResult"] + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.UpdateLongTermRetentionBackupParameters", + **kwargs: Any + ) -> LROPoller["_models.LongTermRetentionBackupOperationResult"]: """Updates an existing long term retention backup. :param location_name: The location of the database. @@ -273,15 +858,20 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -295,29 +885,21 @@ def begin_update( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -329,17 +911,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + @distributed_trace def get( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LongTermRetentionBackup" + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> "_models.LongTermRetentionBackup": """Gets a long term retention backup. :param location_name: The location of the database. @@ -360,29 +943,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -396,43 +969,36 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + def _delete_initial( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -445,15 +1011,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a long term retention backup. :param location_name: The location of the database. @@ -466,15 +1033,17 @@ def begin_delete( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -490,23 +1059,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -518,18 +1078,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_database( self, - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LongTermRetentionBackupListResult"] + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.LongTermRetentionBackupListResult"]: """Lists all long term retention backups for a database. :param location_name: The location of the database. @@ -545,7 +1106,8 @@ def list_by_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -554,41 +1116,39 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -606,19 +1166,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_location( self, - location_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LongTermRetentionBackupListResult"] + location_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.LongTermRetentionBackupListResult"]: """Lists the long term retention backups for a given location. :param location_name: The location of the database. @@ -630,7 +1191,8 @@ def list_by_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -639,39 +1201,35 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -689,20 +1247,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_server( self, - location_name, # type: str - long_term_retention_server_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LongTermRetentionBackupListResult"] + location_name: str, + long_term_retention_server_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.LongTermRetentionBackupListResult"]: """Lists the long term retention backups for a given server. :param location_name: The location of the database. @@ -716,7 +1275,8 @@ def list_by_server( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -725,40 +1285,37 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -776,6 +1333,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -783,49 +1341,38 @@ def get_next(next_link=None): def _copy_by_resource_group_initial( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.CopyLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LongTermRetentionBackupOperationResult"] + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.CopyLongTermRetentionBackupParameters", + **kwargs: Any + ) -> Optional["_models.LongTermRetentionBackupOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LongTermRetentionBackupOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._copy_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_copy_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._copy_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CopyLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -841,19 +1388,21 @@ def _copy_by_resource_group_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _copy_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore + + @distributed_trace def begin_copy_by_resource_group( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.CopyLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LongTermRetentionBackupOperationResult"] + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.CopyLongTermRetentionBackupParameters", + **kwargs: Any + ) -> LROPoller["_models.LongTermRetentionBackupOperationResult"]: """Copy an existing long term retention backup to a different server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -871,15 +1420,20 @@ def begin_copy_by_resource_group( :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -894,30 +1448,21 @@ def begin_copy_by_resource_group( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -929,53 +1474,43 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_copy_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy'} # type: ignore def _update_by_resource_group_initial( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.UpdateLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LongTermRetentionBackupOperationResult"] + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.UpdateLongTermRetentionBackupParameters", + **kwargs: Any + ) -> Optional["_models.LongTermRetentionBackupOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LongTermRetentionBackupOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UpdateLongTermRetentionBackupParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -991,19 +1526,21 @@ def _update_by_resource_group_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + + @distributed_trace def begin_update_by_resource_group( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - parameters, # type: "_models.UpdateLongTermRetentionBackupParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LongTermRetentionBackupOperationResult"] + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: "_models.UpdateLongTermRetentionBackupParameters", + **kwargs: Any + ) -> LROPoller["_models.LongTermRetentionBackupOperationResult"]: """Updates an existing long term retention backup. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1021,15 +1558,20 @@ def begin_update_by_resource_group( :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters :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. + :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 LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :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 LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionBackupOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1044,30 +1586,21 @@ def begin_update_by_resource_group( long_term_retention_database_name=long_term_retention_database_name, backup_name=backup_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionBackupOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1079,18 +1612,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update'} # type: ignore + @distributed_trace def get_by_resource_group( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LongTermRetentionBackup" + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> "_models.LongTermRetentionBackup": """Gets a long term retention backup. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1114,30 +1648,20 @@ def get_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1151,45 +1675,38 @@ def get_by_resource_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + def _delete_by_resource_group_initial( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1202,16 +1719,17 @@ def _delete_by_resource_group_initial( _delete_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + + @distributed_trace def begin_delete_by_resource_group( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a long term retention backup. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1227,15 +1745,17 @@ def begin_delete_by_resource_group( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1252,24 +1772,14 @@ def begin_delete_by_resource_group( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1281,19 +1791,20 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_resource_group_database( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - long_term_retention_database_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LongTermRetentionBackupListResult"] + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.LongTermRetentionBackupListResult"]: """Lists all long term retention backups for a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1312,7 +1823,8 @@ def list_by_resource_group_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -1321,42 +1833,41 @@ def list_by_resource_group_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'longTermRetentionDatabaseName': self._serialize.url("long_term_retention_database_name", long_term_retention_database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1374,20 +1885,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_resource_group_location( self, - resource_group_name, # type: str - location_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LongTermRetentionBackupListResult"] + resource_group_name: str, + location_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.LongTermRetentionBackupListResult"]: """Lists the long term retention backups for a given location. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1402,7 +1914,8 @@ def list_by_resource_group_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -1411,40 +1924,37 @@ def list_by_resource_group_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1462,21 +1972,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups'} # type: ignore + @distributed_trace def list_by_resource_group_server( self, - resource_group_name, # type: str - location_name, # type: str - long_term_retention_server_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LongTermRetentionBackupListResult"] + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.LongTermRetentionBackupListResult"]: """Lists the long term retention backups for a given server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1493,7 +2004,8 @@ def list_by_resource_group_server( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of cls(response) + :return: An iterator like instance of either LongTermRetentionBackupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -1502,41 +2014,39 @@ def list_by_resource_group_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'longTermRetentionServerName': self._serialize.url("long_term_retention_server_name", long_term_retention_server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_server_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_server_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1554,6 +2064,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_managed_instance_backups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_managed_instance_backups_operations.py index dff4bb682835e..9283b27eafbbc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_managed_instance_backups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_managed_instance_backups_operations.py @@ -5,25 +5,433 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_get_request( + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_database_request( + location_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_instance_request( + location_name: str, + managed_instance_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_location_request( + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_resource_group_request( + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_resource_group_request_initial( + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "backupName": _SERIALIZER.url("backup_name", backup_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_resource_group_database_request( + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_instance_request( + resource_group_name: str, + location_name: str, + managed_instance_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_location_request( + resource_group_name: str, + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_latest_per_database is not None: + query_parameters['onlyLatestPerDatabase'] = _SERIALIZER.query("only_latest_per_database", only_latest_per_database, 'bool') + if database_state is not None: + query_parameters['databaseState'] = _SERIALIZER.query("database_state", database_state, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LongTermRetentionManagedInstanceBackupsOperations(object): """LongTermRetentionManagedInstanceBackupsOperations operations. @@ -47,15 +455,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceLongTermRetentionBackup" + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> "_models.ManagedInstanceLongTermRetentionBackup": """Gets a long term retention backup for a managed database. :param location_name: The location of the database. @@ -76,29 +484,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,43 +510,36 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + def _delete_initial( self, - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -161,15 +552,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a long term retention backup. :param location_name: The location of the database. @@ -182,15 +574,17 @@ def begin_delete( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -206,23 +600,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -234,18 +619,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_database( self, - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"] + location_name: str, + managed_instance_name: str, + database_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"]: """Lists all long term retention backups for a managed database. :param location_name: The location of the database. @@ -261,8 +647,10 @@ def list_by_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -270,41 +658,39 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -322,20 +708,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_instance( self, - location_name, # type: str - managed_instance_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"] + location_name: str, + managed_instance_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"]: """Lists the long term retention backups for a given managed instance. :param location_name: The location of the database. @@ -349,8 +736,10 @@ def list_by_instance( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -358,40 +747,37 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -409,19 +795,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_location( self, - location_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"] + location_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"]: """Lists the long term retention backups for managed databases in a given location. :param location_name: The location of the database. @@ -433,8 +820,10 @@ def list_by_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -442,39 +831,35 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -492,21 +877,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def get_by_resource_group( self, - resource_group_name, # type: str - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceLongTermRetentionBackup" + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> "_models.ManagedInstanceLongTermRetentionBackup": """Gets a long term retention backup for a managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -530,30 +916,20 @@ def get_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -567,45 +943,38 @@ def get_by_resource_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + def _delete_by_resource_group_initial( self, - resource_group_name, # type: str - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_by_resource_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_resource_group_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_by_resource_group_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -618,16 +987,17 @@ def _delete_by_resource_group_initial( _delete_by_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + + @distributed_trace def begin_delete_by_resource_group( self, - resource_group_name, # type: str - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - backup_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a long term retention backup. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -643,15 +1013,17 @@ def begin_delete_by_resource_group( :type backup_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -668,24 +1040,14 @@ def begin_delete_by_resource_group( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'backupName': self._serialize.url("backup_name", backup_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -697,19 +1059,20 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}'} # type: ignore + @distributed_trace def list_by_resource_group_database( self, - resource_group_name, # type: str - location_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"] + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"]: """Lists all long term retention backups for a managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -728,8 +1091,10 @@ def list_by_resource_group_database( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -737,42 +1102,41 @@ def list_by_resource_group_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_database_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -790,21 +1154,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_resource_group_instance( self, - resource_group_name, # type: str - location_name, # type: str - managed_instance_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"] + resource_group_name: str, + location_name: str, + managed_instance_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"]: """Lists the long term retention backups for a given managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -821,8 +1186,10 @@ def list_by_resource_group_instance( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -830,41 +1197,39 @@ def list_by_resource_group_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_instance_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_instance_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -882,20 +1247,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups'} # type: ignore + @distributed_trace def list_by_resource_group_location( self, - resource_group_name, # type: str - location_name, # type: str - only_latest_per_database=None, # type: Optional[bool] - database_state=None, # type: Optional[Union[str, "_models.DatabaseState"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"] + resource_group_name: str, + location_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, "_models.DatabaseState"]] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackupListResult"]: """Lists the long term retention backups for managed databases in a given location. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -910,8 +1276,10 @@ def list_by_resource_group_location( all databases. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackupListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionBackupListResult"] @@ -919,40 +1287,37 @@ def list_by_resource_group_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if only_latest_per_database is not None: - query_parameters['onlyLatestPerDatabase'] = self._serialize.query("only_latest_per_database", only_latest_per_database, 'bool') - if database_state is not None: - query_parameters['databaseState'] = self._serialize.query("database_state", database_state, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=self.list_by_resource_group_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionBackupListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionBackupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -970,6 +1335,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_policies_operations.py index 218ed058beaeb..2a5d19ffc6715 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_policies_operations.py @@ -5,25 +5,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.LongTermRetentionPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.LongTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LongTermRetentionPoliciesOperations(object): """LongTermRetentionPoliciesOperations operations. @@ -47,15 +174,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.LongTermRetentionPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.LongTermRetentionPolicy" + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.LongTermRetentionPolicyName"], + **kwargs: Any + ) -> "_models.LongTermRetentionPolicy": """Gets a database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,29 +204,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,51 +230,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.LongTermRetentionPolicyName"] - parameters, # type: "_models.LongTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LongTermRetentionPolicy"] + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.LongTermRetentionPolicyName"], + parameters: "_models.LongTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.LongTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LongTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'LongTermRetentionPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LongTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,18 +281,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.LongTermRetentionPolicyName"] - parameters, # type: "_models.LongTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LongTermRetentionPolicy"] + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, "_models.LongTermRetentionPolicyName"], + parameters: "_models.LongTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.LongTermRetentionPolicy"]: """Sets a database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -200,15 +310,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy :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. + :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 LongTermRetentionPolicy or the result of cls(response) + :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 LongTermRetentionPolicy or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LongTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -222,29 +336,21 @@ def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LongTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,16 +362,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LongTermRetentionPolicyListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.LongTermRetentionPolicyListResult"]: """Gets a database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -276,7 +383,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionPolicyListResult or the result of cls(response) + :return: An iterator like instance of either LongTermRetentionPolicyListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -285,37 +393,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LongTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("LongTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,6 +439,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_window_options_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_window_options_operations.py index 81f9feecdab46..608f94a231f23 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_window_options_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_window_options_operations.py @@ -5,22 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + maintenance_window_options_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindowOptions/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['maintenanceWindowOptionsName'] = _SERIALIZER.query("maintenance_window_options_name", maintenance_window_options_name, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class MaintenanceWindowOptionsOperations(object): """MaintenanceWindowOptionsOperations operations. @@ -44,15 +86,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - maintenance_window_options_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MaintenanceWindowOptions" + resource_group_name: str, + server_name: str, + database_name: str, + maintenance_window_options_name: str, + **kwargs: Any + ) -> "_models.MaintenanceWindowOptions": """Gets a list of available maintenance windows. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,29 +116,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['maintenanceWindowOptionsName'] = self._serialize.query("maintenance_window_options_name", maintenance_window_options_name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_options_name=maintenance_window_options_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,4 +142,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindowOptions/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py index 20f9f47535582..74ce1175156e7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py @@ -5,22 +5,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + maintenance_window_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['maintenanceWindowName'] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + maintenance_window_name: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['maintenanceWindowName'] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class MaintenanceWindowsOperations(object): """MaintenanceWindowsOperations operations. @@ -44,15 +133,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - maintenance_window_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MaintenanceWindows" + resource_group_name: str, + server_name: str, + database_name: str, + maintenance_window_name: str, + **kwargs: Any + ) -> "_models.MaintenanceWindows": """Gets maintenance windows settings for a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,29 +163,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['maintenanceWindowName'] = self._serialize.query("maintenance_window_name", maintenance_window_name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_name=maintenance_window_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,18 +189,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - maintenance_window_name, # type: str - parameters, # type: "_models.MaintenanceWindows" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + maintenance_window_name: str, + parameters: "_models.MaintenanceWindows", + **kwargs: Any + ) -> None: """Sets maintenance windows settings for a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -145,32 +226,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['maintenanceWindowName'] = self._serialize.query("maintenance_window_name", maintenance_window_name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'MaintenanceWindows') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + maintenance_window_name=maintenance_window_name, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MaintenanceWindows') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,3 +255,4 @@ def create_or_update( return cls(pipeline_response, None, {}) create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py index 54b56086c4583..4479970221328 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py @@ -5,25 +5,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}') + 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'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}') + 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'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}') + 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'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedBackupShortTermRetentionPoliciesOperations(object): """ManagedBackupShortTermRetentionPoliciesOperations operations. @@ -47,15 +222,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedBackupShortTermRetentionPolicy" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + **kwargs: Any + ) -> "_models.ManagedBackupShortTermRetentionPolicy": """Gets a managed database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,29 +252,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,51 +278,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedBackupShortTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,18 +329,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"]: """Updates a managed database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -200,15 +358,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedBackupShortTermRetentionPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -222,29 +385,21 @@ def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,51 +411,41 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedBackupShortTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,18 +461,20 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"]: """Updates a managed database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -343,15 +490,20 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedBackupShortTermRetentionPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -365,29 +517,21 @@ def begin_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -399,16 +543,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedBackupShortTermRetentionPolicyListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedBackupShortTermRetentionPolicyListResult"]: """Gets a managed database's short term retention policy list. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -419,8 +564,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] + :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicyListResult"] @@ -428,37 +575,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -476,6 +621,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_columns_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_columns_operations.py index 30e140091d684..be97402595714 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_columns_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_columns_operations.py @@ -5,23 +5,166 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/columns') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if schema is not None: + query_parameters['schema'] = [_SERIALIZER.query("schema", q, 'str') if q is not None else '' for q in schema] + if table is not None: + query_parameters['table'] = [_SERIALIZER.query("table", q, 'str') if q is not None else '' for q in table] + if column is not None: + query_parameters['column'] = [_SERIALIZER.query("column", q, 'str') if q is not None else '' for q in column] + if order_by is not None: + query_parameters['orderBy'] = [_SERIALIZER.query("order_by", q, 'str') if q is not None else '' for q in order_by] + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_table_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseColumnsOperations(object): """ManagedDatabaseColumnsOperations operations. @@ -45,19 +188,19 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema=None, # type: Optional[List[str]] - table=None, # type: Optional[List[str]] - column=None, # type: Optional[List[str]] - order_by=None, # type: Optional[List[str]] - skiptoken=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseColumnListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseColumnListResult"]: """List managed database columns. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -78,7 +221,8 @@ def list_by_database( :param skiptoken: An opaque token that identifies a starting point in the collection. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -87,47 +231,45 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if schema is not None: - query_parameters['schema'] = [self._serialize.query("schema", q, 'str') if q is not None else '' for q in schema] - if table is not None: - query_parameters['table'] = [self._serialize.query("table", q, 'str') if q is not None else '' for q in table] - if column is not None: - query_parameters['column'] = [self._serialize.query("column", q, 'str') if q is not None else '' for q in column] - if order_by is not None: - query_parameters['orderBy'] = [self._serialize.query("order_by", q, 'str') if q is not None else '' for q in order_by] - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -145,22 +287,23 @@ def get_next(next_link=None): 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}/columns'} # type: ignore + @distributed_trace def list_by_table( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseColumnListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseColumnListResult"]: """List managed database columns. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -177,7 +320,8 @@ def list_by_table( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseColumnListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseColumnListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumnListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -186,41 +330,41 @@ def list_by_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_table.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_table_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseColumnListResult', pipeline_response) + deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -238,22 +382,23 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseColumn" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> "_models.DatabaseColumn": """Get managed database column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -279,31 +424,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -317,4 +452,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py index 7c3949d29f8de..7f883ae5d81e3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py @@ -5,23 +5,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}') + 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'), + "queryId": _SERIALIZER.url("query_id", query_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_query_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + subscription_id: str, + *, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, "_models.QueryTimeGrainType"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}/statistics') + 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'), + "queryId": _SERIALIZER.url("query_id", query_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if start_time is not None: + query_parameters['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + if end_time is not None: + query_parameters['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseQueriesOperations(object): """ManagedDatabaseQueriesOperations operations. @@ -45,15 +135,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - query_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceQuery" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + **kwargs: Any + ) -> "_models.ManagedInstanceQuery": """Get query by query id. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -75,29 +165,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'queryId': self._serialize.url("query_id", query_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,20 +191,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}'} # type: ignore + + @distributed_trace def list_by_query( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - query_id, # type: str - start_time=None, # type: Optional[str] - end_time=None, # type: Optional[str] - interval=None, # type: Optional[Union[str, "_models.QueryTimeGrainType"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceQueryStatistics"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, "_models.QueryTimeGrainType"]] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceQueryStatistics"]: """Get query execution statistics by query id. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -143,7 +225,8 @@ def list_by_query( :param interval: The time step to be used to summarize the metric values. :type interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceQueryStatistics or the result of cls(response) + :return: An iterator like instance of either ManagedInstanceQueryStatistics or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceQueryStatistics] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -152,44 +235,43 @@ def list_by_query( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_query.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'queryId': self._serialize.url("query_id", query_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - if end_time is not None: - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_query_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + interval=interval, + template_url=self.list_by_query.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_query_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + interval=interval, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceQueryStatistics', pipeline_response) + deserialized = self._deserialize("ManagedInstanceQueryStatistics", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -207,6 +289,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py index 2a7efa315d866..1c947249b0d54 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py @@ -5,22 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ManagedDatabaseRecommendedSensitivityLabelsOperations(object): """ManagedDatabaseRecommendedSensitivityLabelsOperations operations. @@ -44,15 +91,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.RecommendedSensitivityLabelUpdateList" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.RecommendedSensitivityLabelUpdateList", + **kwargs: Any + ) -> None: """Update recommended sensitivity labels states of a given database using an operations batch. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,31 +121,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') + + request = build_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,3 +149,4 @@ def update( return cls(pipeline_response, None, {}) update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py index 4aca96ed11d17..98dc158b0ffc5 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py @@ -5,22 +5,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + restore_details_name: Union[str, "_models.RestoreDetailsName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}') + 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'), + "restoreDetailsName": _SERIALIZER.url("restore_details_name", restore_details_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseRestoreDetailsOperations(object): """ManagedDatabaseRestoreDetailsOperations operations. @@ -44,15 +85,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - restore_details_name, # type: Union[str, "_models.RestoreDetailsName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedDatabaseRestoreDetailsResult" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + restore_details_name: Union[str, "_models.RestoreDetailsName"], + **kwargs: Any + ) -> "_models.ManagedDatabaseRestoreDetailsResult": """Gets managed database restore details. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,29 +115,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'restoreDetailsName': self._serialize.url("restore_details_name", restore_details_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + restore_details_name=restore_details_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,4 +141,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py index 02ee053bbc3cd..84bd9b0a6db24 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py @@ -5,23 +5,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseSchemasOperations(object): """ManagedDatabaseSchemasOperations operations. @@ -45,15 +127,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseSchemaListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseSchemaListResult"]: """List managed database schemas. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -66,7 +148,8 @@ def list_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseSchemaListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseSchemaListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSchemaListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -75,39 +158,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseSchemaListResult', pipeline_response) + deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,20 +206,21 @@ def get_next(next_link=None): 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}/schemas'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseSchema" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + **kwargs: Any + ) -> "_models.DatabaseSchema": """Get managed database schema. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -160,29 +242,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -196,4 +268,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py index 5ebb932f7b587..70a62f2f982f2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py @@ -5,23 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}') + 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'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}') + 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'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseSecurityAlertPoliciesOperations(object): """ManagedDatabaseSecurityAlertPoliciesOperations operations. @@ -45,15 +172,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedDatabaseSecurityAlertPolicy" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + **kwargs: Any + ) -> "_models.ManagedDatabaseSecurityAlertPolicy": """Gets a managed database's security alert policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -76,29 +203,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,18 +229,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - parameters, # type: "_models.ManagedDatabaseSecurityAlertPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedDatabaseSecurityAlertPolicy" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: "_models.ManagedDatabaseSecurityAlertPolicy", + **kwargs: Any + ) -> "_models.ManagedDatabaseSecurityAlertPolicy": """Creates or updates a database's security alert policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,34 +267,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedDatabaseSecurityAlertPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedDatabaseSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -193,16 +302,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedDatabaseSecurityAlertPolicyListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedDatabaseSecurityAlertPolicyListResult"]: """Gets a list of managed database's security alert policies. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -214,8 +325,10 @@ def list_by_database( are defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedDatabaseSecurityAlertPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicyListResult] + :return: An iterator like instance of either ManagedDatabaseSecurityAlertPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabaseSecurityAlertPolicyListResult"] @@ -223,37 +336,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedDatabaseSecurityAlertPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedDatabaseSecurityAlertPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -271,6 +382,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_events_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_events_operations.py index b6758abdefba4..786489e8662a9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_events_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_events_operations.py @@ -5,23 +5,75 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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, + *, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityEvents') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseSecurityEventsOperations(object): """ManagedDatabaseSecurityEventsOperations operations. @@ -45,18 +97,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - filter=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - skiptoken=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityEventCollection"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SecurityEventCollection"]: """Gets a list of security events. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -76,7 +128,8 @@ def list_by_database( :param skiptoken: An opaque token that identifies a starting point in the collection. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityEventCollection or the result of cls(response) + :return: An iterator like instance of either SecurityEventCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SecurityEventCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -85,45 +138,43 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + skip=skip, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + skip=skip, + top=top, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SecurityEventCollection', pipeline_response) + deserialized = self._deserialize("SecurityEventCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -141,6 +192,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py index 9ecc87acd8290..a4819712a0ed7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py @@ -5,23 +5,380 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + sensitivity_label_source: Union[str, "_models.SensitivityLabelSource"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + sensitivity_label_source = "current" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + sensitivity_label_source = "current" + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_disable_recommendation_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + sensitivity_label_source = "recommended" + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_enable_recommendation_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + sensitivity_label_source = "recommended" + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_current_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + if count is not None: + query_parameters['$count'] = _SERIALIZER.query("count", count, 'bool') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_recommended_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + if include_disabled_recommendations is not None: + query_parameters['includeDisabledRecommendations'] = _SERIALIZER.query("include_disabled_recommendations", include_disabled_recommendations, 'bool') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseSensitivityLabelsOperations(object): """ManagedDatabaseSensitivityLabelsOperations operations. @@ -45,18 +402,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - sensitivity_label_source, # type: Union[str, "_models.SensitivityLabelSource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SensitivityLabel" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + sensitivity_label_source: Union[str, "_models.SensitivityLabelSource"], + **kwargs: Any + ) -> "_models.SensitivityLabel": """Gets the sensitivity label of a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -84,32 +441,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + sensitivity_label_source=sensitivity_label_source, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -123,20 +470,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - parameters, # type: "_models.SensitivityLabel" - **kwargs # type: Any - ): - # type: (...) -> "_models.SensitivityLabel" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: "_models.SensitivityLabel", + **kwargs: Any + ) -> "_models.SensitivityLabel": """Creates or updates the sensitivity label of a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -164,38 +513,26 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SensitivityLabel') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,19 +550,21 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: """Deletes the sensitivity label of a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -251,31 +590,21 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -288,17 +617,18 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace def disable_recommendation( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: """Disables sensitivity recommendations on a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -324,31 +654,21 @@ def disable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.disable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_disable_recommendation_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.disable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -361,17 +681,18 @@ def disable_recommendation( disable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable'} # type: ignore + + @distributed_trace def enable_recommendation( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: """Enables sensitivity recommendations on a given column (recommendations are enabled by default on all columns). @@ -398,31 +719,21 @@ def enable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.enable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_enable_recommendation_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.enable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -435,17 +746,18 @@ def enable_recommendation( enable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable'} # type: ignore + + @distributed_trace def list_current_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - skip_token=None, # type: Optional[str] - count=None, # type: Optional[bool] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SensitivityLabelListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SensitivityLabelListResult"]: """Gets the sensitivity labels of a given database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -462,7 +774,8 @@ def list_current_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -471,43 +784,41 @@ def list_current_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_current_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if count is not None: - query_parameters['$count'] = self._serialize.query("count", count, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_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, + skip_token=skip_token, + count=count, + filter=filter, + template_url=self.list_current_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_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, + skip_token=skip_token, + count=count, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,20 +836,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_current_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.SensitivityLabelUpdateList" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.SensitivityLabelUpdateList", + **kwargs: Any + ) -> None: """Update sensitivity labels of a given database using an operations batch. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -560,31 +872,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'SensitivityLabelUpdateList') + + request = build_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -597,17 +901,18 @@ def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + + @distributed_trace def list_recommended_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - skip_token=None, # type: Optional[str] - include_disabled_recommendations=None, # type: Optional[bool] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SensitivityLabelListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SensitivityLabelListResult"]: """Gets the sensitivity labels of a given database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -625,7 +930,8 @@ def list_recommended_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -634,43 +940,41 @@ def list_recommended_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_recommended_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if include_disabled_recommendations is not None: - query_parameters['includeDisabledRecommendations'] = self._serialize.query("include_disabled_recommendations", include_disabled_recommendations, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_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, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=self.list_recommended_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_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, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -688,6 +992,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_tables_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_tables_operations.py index 090fd1251361c..8b304d85d58b9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_tables_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_tables_operations.py @@ -5,23 +5,109 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_schema_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}') + 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'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseTablesOperations(object): """ManagedDatabaseTablesOperations operations. @@ -45,16 +131,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_schema( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseTableListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DatabaseTableListResult"]: """List managed database tables. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -69,7 +155,8 @@ def list_by_schema( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseTableListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseTableListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseTableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -78,40 +165,39 @@ def list_by_schema( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_schema.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_schema.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_schema_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseTableListResult', pipeline_response) + deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,21 +215,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseTable" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + **kwargs: Any + ) -> "_models.DatabaseTable": """Get managed database table. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -167,30 +254,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,4 +281,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py index e1d9bff8f63ab..a32407dcc8583 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py @@ -5,23 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}') + 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'), + "tdeName": _SERIALIZER.url("tde_name", tde_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}') + 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'), + "tdeName": _SERIALIZER.url("tde_name", tde_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseTransparentDataEncryptionOperations(object): """ManagedDatabaseTransparentDataEncryptionOperations operations. @@ -45,15 +172,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - tde_name, # type: Union[str, "_models.TransparentDataEncryptionName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedTransparentDataEncryption" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + **kwargs: Any + ) -> "_models.ManagedTransparentDataEncryption": """Gets a managed database's transparent data encryption. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -76,29 +203,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,18 +229,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - tde_name, # type: Union[str, "_models.TransparentDataEncryptionName"] - parameters, # type: "_models.ManagedTransparentDataEncryption" - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedTransparentDataEncryption" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + parameters: "_models.ManagedTransparentDataEncryption", + **kwargs: Any + ) -> "_models.ManagedTransparentDataEncryption": """Updates a database's transparent data encryption configuration. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,34 +267,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedTransparentDataEncryption') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedTransparentDataEncryption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -193,16 +302,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedTransparentDataEncryptionListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedTransparentDataEncryptionListResult"]: """Gets a list of managed database's transparent data encryptions. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -214,8 +325,10 @@ def list_by_database( encryption is defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedTransparentDataEncryptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryptionListResult] + :return: An iterator like instance of either ManagedTransparentDataEncryptionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedTransparentDataEncryptionListResult"] @@ -223,37 +336,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedTransparentDataEncryptionListResult', pipeline_response) + deserialized = self._deserialize("ManagedTransparentDataEncryptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -271,6 +382,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py index 5dab140f6ad71..bdfef89a87394 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py @@ -5,22 +5,157 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations(object): """ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations. @@ -44,17 +179,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - rule_id, # type: str - baseline_name, # type: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline": """Gets a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -82,31 +217,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -120,20 +245,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - rule_id, # type: str - baseline_name, # type: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"] - parameters, # type: "_models.DatabaseVulnerabilityAssessmentRuleBaseline" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + parameters: "_models.DatabaseVulnerabilityAssessmentRuleBaseline", + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessmentRuleBaseline": """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -163,36 +290,26 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessmentRuleBaseline') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -206,19 +323,21 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - rule_id, # type: str - baseline_name, # type: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + **kwargs: Any + ) -> None: """Removes the database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -246,29 +365,21 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'baselineName': self._serialize.url("baseline_name", baseline_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -280,3 +391,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py index ed1fb799e8f35..c8bde5dc215ec 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py @@ -5,25 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_initiate_scan_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_export_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseVulnerabilityAssessmentScansOperations(object): """ManagedDatabaseVulnerabilityAssessmentScansOperations operations. @@ -49,41 +207,32 @@ def __init__(self, client, config, serializer, deserializer): def _initiate_scan_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._initiate_scan_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_initiate_scan_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self._initiate_scan_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,16 +245,17 @@ def _initiate_scan_initial( _initiate_scan_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + + @distributed_trace def begin_initiate_scan( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> LROPoller[None]: """Executes a Vulnerability Assessment database scan. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -121,15 +271,17 @@ def begin_initiate_scan( :type scan_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -146,24 +298,14 @@ def begin_initiate_scan( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -175,18 +317,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_initiate_scan.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan'} # type: ignore + @distributed_trace def export( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessmentScansExport" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessmentScansExport": """Convert an existing scan result to a human readable format. If already exists nothing happens. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -210,30 +353,20 @@ def export( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.export.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.export.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -251,17 +384,19 @@ def export( return cls(pipeline_response, deserialized, {}) return deserialized + export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VulnerabilityAssessmentScanRecordListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> Iterable["_models.VulnerabilityAssessmentScanRecordListResult"]: """Lists the vulnerability assessment scans of a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -274,8 +409,10 @@ def list_by_database( :param vulnerability_assessment_name: The name of the vulnerability assessment. :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] + :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecordListResult"] @@ -283,38 +420,37 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VulnerabilityAssessmentScanRecordListResult', pipeline_response) + deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -332,21 +468,22 @@ def get_next(next_link=None): 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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - scan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VulnerabilityAssessmentScanRecord" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + scan_id: str, + **kwargs: Any + ) -> "_models.VulnerabilityAssessmentScanRecord": """Gets a vulnerability assessment scan record of a database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -370,30 +507,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -407,4 +534,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py index beada1a289ca5..4926af5347f0d 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py @@ -5,23 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + 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'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabaseVulnerabilityAssessmentsOperations(object): """ManagedDatabaseVulnerabilityAssessmentsOperations operations. @@ -45,15 +205,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessment" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessment": """Gets the database's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -76,29 +236,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,18 +262,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - parameters, # type: "_models.DatabaseVulnerabilityAssessment" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseVulnerabilityAssessment" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: "_models.DatabaseVulnerabilityAssessment", + **kwargs: Any + ) -> "_models.DatabaseVulnerabilityAssessment": """Creates or updates the database's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,34 +300,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DatabaseVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -193,17 +335,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> None: """Removes the database's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -226,27 +370,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -259,14 +395,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseVulnerabilityAssessmentListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseVulnerabilityAssessmentListResult"]: """Lists the vulnerability assessments of a managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -278,8 +415,10 @@ def list_by_database( defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] + :return: An iterator like instance of either DatabaseVulnerabilityAssessmentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseVulnerabilityAssessmentListResult"] @@ -287,37 +426,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -335,6 +472,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_databases_operations.py index 07682632131cd..26ca6c95b2e39 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_databases_operations.py @@ -5,25 +5,302 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_complete_restore_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_inaccessible_by_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/inaccessibleManagedDatabases') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedDatabasesOperations(object): """ManagedDatabasesOperations operations. @@ -47,13 +324,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedDatabaseListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedDatabaseListResult"]: """Gets a list of managed databases. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -62,7 +339,8 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedDatabaseListResult or the result of cls(response) + :return: An iterator like instance of either ManagedDatabaseListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,36 +349,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,19 +393,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedDatabase" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.ManagedDatabase": """Gets a managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -150,28 +426,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,49 +451,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.ManagedDatabase" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedDatabase"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.ManagedDatabase", + **kwargs: Any + ) -> Optional["_models.ManagedDatabase"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedDatabase"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedDatabase') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedDatabase') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,17 +503,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.ManagedDatabase" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedDatabase"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.ManagedDatabase", + **kwargs: Any + ) -> LROPoller["_models.ManagedDatabase"]: """Creates a new database or updates an existing database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -270,15 +529,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedDatabase :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. + :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 ManagedDatabase or the result of cls(response) + :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 ManagedDatabase or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabase"] lro_delay = kwargs.pop( 'polling_interval', @@ -291,28 +554,21 @@ def begin_create_or_update( managed_instance_name=managed_instance_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedDatabase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -324,41 +580,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -371,14 +619,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -390,15 +639,17 @@ def begin_delete( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -413,22 +664,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -440,49 +683,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.ManagedDatabaseUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedDatabase"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.ManagedDatabaseUpdate", + **kwargs: Any + ) -> Optional["_models.ManagedDatabase"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedDatabase"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedDatabaseUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedDatabaseUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -498,17 +731,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.ManagedDatabaseUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedDatabase"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.ManagedDatabaseUpdate", + **kwargs: Any + ) -> LROPoller["_models.ManagedDatabase"]: """Updates an existing database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -522,15 +757,19 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate :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. + :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 ManagedDatabase or the result of cls(response) + :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 ManagedDatabase or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedDatabase"] lro_delay = kwargs.pop( 'polling_interval', @@ -543,28 +782,21 @@ def begin_update( managed_instance_name=managed_instance_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedDatabase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -576,47 +808,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}'} # type: ignore def _complete_restore_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.CompleteDatabaseRestoreDefinition" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.CompleteDatabaseRestoreDefinition", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._complete_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'CompleteDatabaseRestoreDefinition') + + request = build_complete_restore_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._complete_restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CompleteDatabaseRestoreDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -629,15 +853,16 @@ def _complete_restore_initial( _complete_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore'} # type: ignore + + @distributed_trace def begin_complete_restore( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - parameters, # type: "_models.CompleteDatabaseRestoreDefinition" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: "_models.CompleteDatabaseRestoreDefinition", + **kwargs: Any + ) -> LROPoller[None]: """Completes the restore operation on a managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -651,15 +876,18 @@ def begin_complete_restore( :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -672,25 +900,18 @@ def begin_complete_restore( managed_instance_name=managed_instance_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -702,15 +923,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_complete_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore'} # type: ignore + @distributed_trace def list_inaccessible_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedDatabaseListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedDatabaseListResult"]: """Gets a list of inaccessible managed databases in a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -719,7 +941,8 @@ def list_inaccessible_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedDatabaseListResult or the result of cls(response) + :return: An iterator like instance of either ManagedDatabaseListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -728,36 +951,33 @@ def list_inaccessible_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_inaccessible_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_inaccessible_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_inaccessible_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -775,6 +995,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py index 6186cadd363bf..d3bca6aec961c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class ManagedInstanceAdministratorsOperations(object): """ManagedInstanceAdministratorsOperations operations. @@ -47,13 +199,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceAdministratorListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceAdministratorListResult"]: """Gets a list of managed instance administrators. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -62,8 +214,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministratorListResult] + :return: An iterator like instance of either ManagedInstanceAdministratorListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAdministratorListResult"] @@ -71,36 +225,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,19 +269,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceAdministrator" + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> "_models.ManagedInstanceAdministrator": """Gets a managed instance administrator. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -150,28 +302,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,49 +327,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - parameters, # type: "_models.ManagedInstanceAdministrator" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstanceAdministrator"] + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: "_models.ManagedInstanceAdministrator", + **kwargs: Any + ) -> Optional["_models.ManagedInstanceAdministrator"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstanceAdministrator"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceAdministrator') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceAdministrator') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,17 +379,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - parameters, # type: "_models.ManagedInstanceAdministrator" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstanceAdministrator"] + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: "_models.ManagedInstanceAdministrator", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstanceAdministrator"]: """Creates or updates a managed instance administrator. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -270,15 +405,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator :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. + :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 ManagedInstanceAdministrator or the result of cls(response) + :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 ManagedInstanceAdministrator or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAdministrator"] lro_delay = kwargs.pop( 'polling_interval', @@ -291,28 +430,21 @@ def begin_create_or_update( managed_instance_name=managed_instance_name, administrator_name=administrator_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceAdministrator', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -324,41 +456,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -371,14 +495,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> LROPoller[None]: """Deletes a managed instance administrator. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -390,15 +515,17 @@ def begin_delete( :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -413,22 +540,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -440,4 +559,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py index c78e633f3828f..4bce86cc37df5 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedInstanceAzureADOnlyAuthenticationsOperations(object): """ManagedInstanceAzureADOnlyAuthenticationsOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceAzureADOnlyAuthentication" + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + **kwargs: Any + ) -> "_models.ManagedInstanceAzureADOnlyAuthentication": """Gets a specific Azure Active Directory only authentication property. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - parameters, # type: "_models.ManagedInstanceAzureADOnlyAuthentication" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstanceAzureADOnlyAuthentication"] + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + parameters: "_models.ManagedInstanceAzureADOnlyAuthentication", + **kwargs: Any + ) -> Optional["_models.ManagedInstanceAzureADOnlyAuthentication"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstanceAzureADOnlyAuthentication"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceAzureADOnlyAuthentication') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceAzureADOnlyAuthentication') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +303,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - parameters, # type: "_models.ManagedInstanceAzureADOnlyAuthentication" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstanceAzureADOnlyAuthentication"] + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + parameters: "_models.ManagedInstanceAzureADOnlyAuthentication", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstanceAzureADOnlyAuthentication"]: """Sets Server Active Directory only authentication property or updates an existing server Active Directory only authentication property. @@ -196,15 +331,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication :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. + :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 ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedInstanceAzureADOnlyAuthentication + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAzureADOnlyAuthentication"] lro_delay = kwargs.pop( 'polling_interval', @@ -217,28 +357,21 @@ def begin_create_or_update( managed_instance_name=managed_instance_name, authentication_name=authentication_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceAzureADOnlyAuthentication', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -250,41 +383,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -297,14 +422,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing server Active Directory only authentication property. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -316,15 +442,17 @@ def begin_delete( :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -339,22 +467,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -366,15 +486,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceAzureADOnlyAuthListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceAzureADOnlyAuthListResult"]: """Gets a list of server Azure Active Directory only authentications. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -383,8 +504,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceAzureADOnlyAuthListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthListResult] + :return: An iterator like instance of either ManagedInstanceAzureADOnlyAuthListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceAzureADOnlyAuthListResult"] @@ -392,36 +515,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceAzureADOnlyAuthListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceAzureADOnlyAuthListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -439,6 +559,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_encryption_protectors_operations.py index aa244fc4d79f6..75a6620f4011b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_encryption_protectors_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_revalidate_request_initial( + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ManagedInstanceEncryptionProtectorsOperations(object): """ManagedInstanceEncryptionProtectorsOperations operations. @@ -49,37 +201,28 @@ def __init__(self, client, config, serializer, deserializer): def _revalidate_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._revalidate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_revalidate_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self._revalidate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,14 +235,15 @@ def _revalidate_initial( _revalidate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore + + @distributed_trace def begin_revalidate( self, - resource_group_name, # type: str - managed_instance_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + **kwargs: Any + ) -> LROPoller[None]: """Revalidates an existing encryption protector. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -111,15 +255,17 @@ def begin_revalidate( :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -134,22 +280,14 @@ def begin_revalidate( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -161,15 +299,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_revalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate'} # type: ignore + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceEncryptionProtectorListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceEncryptionProtectorListResult"]: """Gets a list of managed instance encryption protectors. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -178,8 +317,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceEncryptionProtectorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtectorListResult] + :return: An iterator like instance of either ManagedInstanceEncryptionProtectorListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtectorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceEncryptionProtectorListResult"] @@ -187,36 +328,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceEncryptionProtectorListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceEncryptionProtectorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -234,19 +372,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceEncryptionProtector" + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + **kwargs: Any + ) -> "_models.ManagedInstanceEncryptionProtector": """Gets a managed instance encryption protector. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -266,28 +405,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -301,49 +430,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - parameters, # type: "_models.ManagedInstanceEncryptionProtector" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstanceEncryptionProtector"] + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: "_models.ManagedInstanceEncryptionProtector", + **kwargs: Any + ) -> Optional["_models.ManagedInstanceEncryptionProtector"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstanceEncryptionProtector"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedInstanceEncryptionProtector') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceEncryptionProtector') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -359,17 +479,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - encryption_protector_name, # type: Union[str, "_models.EncryptionProtectorName"] - parameters, # type: "_models.ManagedInstanceEncryptionProtector" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstanceEncryptionProtector"] + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: "_models.ManagedInstanceEncryptionProtector", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstanceEncryptionProtector"]: """Updates an existing encryption protector. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -383,15 +505,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector :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. + :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 ManagedInstanceEncryptionProtector or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedInstanceEncryptionProtector or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceEncryptionProtector"] lro_delay = kwargs.pop( 'polling_interval', @@ -404,28 +531,21 @@ def begin_create_or_update( managed_instance_name=managed_instance_name, encryption_protector_name=encryption_protector_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceEncryptionProtector', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'encryptionProtectorName': self._serialize.url("encryption_protector_name", encryption_protector_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -437,4 +557,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py index 5aaecd814980a..ebca85079f091 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py @@ -5,25 +5,181 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + key_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + key_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + managed_instance_name: str, + key_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class ManagedInstanceKeysOperations(object): """ManagedInstanceKeysOperations operations. @@ -47,14 +203,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceKeyListResult"] + resource_group_name: str, + managed_instance_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceKeyListResult"]: """Gets a list of managed instance keys. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -65,7 +221,8 @@ def list_by_instance( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceKeyListResult or the result of cls(response) + :return: An iterator like instance of either ManagedInstanceKeyListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceKeyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -74,38 +231,35 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceKeyListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceKeyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,19 +277,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceKey" + resource_group_name: str, + managed_instance_name: str, + key_name: str, + **kwargs: Any + ) -> "_models.ManagedInstanceKey": """Gets a managed instance key. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -155,28 +310,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -190,49 +335,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - key_name, # type: str - parameters, # type: "_models.ManagedInstanceKey" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstanceKey"] + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: "_models.ManagedInstanceKey", + **kwargs: Any + ) -> Optional["_models.ManagedInstanceKey"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstanceKey"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceKey') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceKey') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -251,17 +387,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - key_name, # type: str - parameters, # type: "_models.ManagedInstanceKey" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstanceKey"] + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: "_models.ManagedInstanceKey", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstanceKey"]: """Creates or updates a managed instance key. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -275,15 +413,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey :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. + :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 ManagedInstanceKey or the result of cls(response) + :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 ManagedInstanceKey or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceKey"] lro_delay = kwargs.pop( 'polling_interval', @@ -296,28 +438,21 @@ def begin_create_or_update( managed_instance_name=managed_instance_name, key_name=key_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceKey', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -329,41 +464,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + key_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -376,14 +503,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + key_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the managed instance key with the given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -395,15 +523,17 @@ def begin_delete( :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -418,22 +548,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -445,4 +567,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py index 7fb3ee9eac76b..ef9651e770895 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py @@ -5,25 +5,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}') + 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'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}') + 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'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedInstanceLongTermRetentionPoliciesOperations(object): """ManagedInstanceLongTermRetentionPoliciesOperations operations. @@ -47,15 +174,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceLongTermRetentionPolicy" + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"], + **kwargs: Any + ) -> "_models.ManagedInstanceLongTermRetentionPolicy": """Gets a managed database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,29 +204,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,51 +230,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"] - parameters, # type: "_models.ManagedInstanceLongTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstanceLongTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"], + parameters: "_models.ManagedInstanceLongTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.ManagedInstanceLongTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstanceLongTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceLongTermRetentionPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceLongTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,18 +281,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - policy_name, # type: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"] - parameters, # type: "_models.ManagedInstanceLongTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstanceLongTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, "_models.ManagedInstanceLongTermRetentionPolicyName"], + parameters: "_models.ManagedInstanceLongTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstanceLongTermRetentionPolicy"]: """Sets a managed database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -200,15 +310,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy :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. + :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 ManagedInstanceLongTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedInstanceLongTermRetentionPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -222,29 +337,21 @@ def begin_create_or_update( database_name=database_name, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstanceLongTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,16 +363,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceLongTermRetentionPolicyListResult"] + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionPolicyListResult"]: """Gets a database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -276,8 +384,10 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyListResult] + :return: An iterator like instance of either ManagedInstanceLongTermRetentionPolicyListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceLongTermRetentionPolicyListResult"] @@ -285,37 +395,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceLongTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,6 +441,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_operations_operations.py index 3119fe1969d66..de97d5ce16d66 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_operations_operations.py @@ -5,23 +5,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_cancel_request( + resource_group_name: str, + managed_instance_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) class ManagedInstanceOperationsOperations(object): """ManagedInstanceOperationsOperations operations. @@ -45,13 +150,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_managed_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceOperationListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceOperationListResult"]: """Gets a list of operations performed on the managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,7 +165,8 @@ def list_by_managed_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceOperationListResult or the result of cls(response) + :return: An iterator like instance of either ManagedInstanceOperationListResult or the result + of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,36 +175,33 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceOperationListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,19 +219,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_managed_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceOperation" + resource_group_name: str, + managed_instance_name: str, + operation_id: str, + **kwargs: Any + ) -> "_models.ManagedInstanceOperation": """Gets a management operation on a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,28 +252,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,16 +277,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}'} # type: ignore + + @distributed_trace def cancel( self, - resource_group_name, # type: str - managed_instance_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + operation_id: str, + **kwargs: Any + ) -> None: """Cancels the asynchronous operation on the managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -212,26 +308,18 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,3 +331,4 @@ def cancel( return cls(pipeline_response, None, {}) cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}/cancel'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py index 4ca0c52fcd8ec..626ca55e5cc6a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_managed_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedInstancePrivateEndpointConnectionsOperations(object): """ManagedInstancePrivateEndpointConnectionsOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstancePrivateEndpointConnection" + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.ManagedInstancePrivateEndpointConnection": """Gets a private endpoint connection. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.ManagedInstancePrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstancePrivateEndpointConnection"] + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: "_models.ManagedInstancePrivateEndpointConnection", + **kwargs: Any + ) -> Optional["_models.ManagedInstancePrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstancePrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstancePrivateEndpointConnection') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstancePrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,17 +300,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.ManagedInstancePrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstancePrivateEndpointConnection"] + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: "_models.ManagedInstancePrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstancePrivateEndpointConnection"]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -191,15 +326,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection :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. + :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 ManagedInstancePrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedInstancePrivateEndpointConnection + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstancePrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -212,28 +352,21 @@ def begin_create_or_update( managed_instance_name=managed_instance_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstancePrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -245,41 +378,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -292,14 +417,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -311,15 +437,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -334,22 +462,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -361,15 +481,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_managed_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstancePrivateEndpointConnectionListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstancePrivateEndpointConnectionListResult"]: """Gets all private endpoint connections on a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -378,8 +499,10 @@ def list_by_managed_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstancePrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionListResult] + :return: An iterator like instance of either ManagedInstancePrivateEndpointConnectionListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstancePrivateEndpointConnectionListResult"] @@ -387,36 +510,33 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstancePrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstancePrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -434,6 +554,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_link_resources_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_link_resources_operations.py index afc7338eb7ebe..86a94249a9cc9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_link_resources_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_link_resources_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources/{groupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "groupName": _SERIALIZER.url("group_name", group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedInstancePrivateLinkResourcesOperations(object): """ManagedInstancePrivateLinkResourcesOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_managed_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstancePrivateLinkListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstancePrivateLinkListResult"]: """Gets the private link resources for SQL server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,8 +134,10 @@ def list_by_managed_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstancePrivateLinkListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLinkListResult] + :return: An iterator like instance of either ManagedInstancePrivateLinkListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstancePrivateLinkListResult"] @@ -69,36 +145,33 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstancePrivateLinkListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstancePrivateLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,19 +189,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_managed_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstancePrivateLink" + resource_group_name: str, + managed_instance_name: str, + group_name: str, + **kwargs: Any + ) -> "_models.ManagedInstancePrivateLink": """Gets a private link resource for SQL server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,28 +222,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,4 +247,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py index ce053f33a96d6..95d69fecf2b93 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py @@ -5,24 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ManagedInstanceTdeCertificatesOperations(object): """ManagedInstanceTdeCertificatesOperations operations. @@ -48,41 +93,32 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - parameters, # type: "_models.TdeCertificate" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + parameters: "_models.TdeCertificate", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'TdeCertificate') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TdeCertificate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,14 +131,15 @@ def _create_initial( _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - managed_instance_name, # type: str - parameters, # type: "_models.TdeCertificate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + parameters: "_models.TdeCertificate", + **kwargs: Any + ) -> LROPoller[None]: """Creates a TDE certificate for a given server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -114,15 +151,18 @@ def begin_create( :type parameters: ~azure.mgmt.sql.models.TdeCertificate :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -134,24 +174,18 @@ def begin_create( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -163,4 +197,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py index 1bced8220f8d4..b62e552999f31 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py @@ -5,23 +5,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedInstanceVulnerabilityAssessmentsOperations(object): """ManagedInstanceVulnerabilityAssessmentsOperations operations. @@ -45,14 +197,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceVulnerabilityAssessment" + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> "_models.ManagedInstanceVulnerabilityAssessment": """Gets the managed instance's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -73,28 +225,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,17 +250,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - parameters, # type: "_models.ManagedInstanceVulnerabilityAssessment" - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstanceVulnerabilityAssessment" + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: "_models.ManagedInstanceVulnerabilityAssessment", + **kwargs: Any + ) -> "_models.ManagedInstanceVulnerabilityAssessment": """Creates or updates the managed instance's vulnerability assessment. Learn more about setting SQL vulnerability assessment with managed identity - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. @@ -143,33 +287,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,16 +321,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> None: """Removes the managed instance's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -217,26 +353,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -249,13 +377,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceVulnerabilityAssessmentListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceVulnerabilityAssessmentListResult"]: """Gets the managed instance's vulnerability assessment policies. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -265,8 +394,10 @@ def list_by_instance( assessments is defined. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessmentListResult] + :return: An iterator like instance of either ManagedInstanceVulnerabilityAssessmentListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstanceVulnerabilityAssessmentListResult"] @@ -274,36 +405,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -321,6 +449,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instances_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instances_operations.py index bc5cd0ce1df56..b5397f4a9fe0c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instances_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instances_operations.py @@ -5,25 +5,385 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_instance_pool_request( + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_managed_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + number_of_queries: Optional[int] = None, + databases: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, "_models.QueryTimeGrainType"]] = None, + aggregation_function: Optional[Union[str, "_models.AggregationFunctionType"]] = None, + observation_metric: Optional[Union[str, "_models.MetricType"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if number_of_queries is not None: + query_parameters['numberOfQueries'] = _SERIALIZER.query("number_of_queries", number_of_queries, 'int') + if databases is not None: + query_parameters['databases'] = _SERIALIZER.query("databases", databases, 'str') + if start_time is not None: + query_parameters['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + if end_time is not None: + query_parameters['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'str') + if aggregation_function is not None: + query_parameters['aggregationFunction'] = _SERIALIZER.query("aggregation_function", aggregation_function, 'str') + if observation_metric is not None: + query_parameters['observationMetric'] = _SERIALIZER.query("observation_metric", observation_metric, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_failover_request_initial( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if replica_type is not None: + query_parameters['replicaType'] = _SERIALIZER.query("replica_type", replica_type, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) class ManagedInstancesOperations(object): """ManagedInstancesOperations operations. @@ -47,14 +407,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance_pool( self, - resource_group_name, # type: str - instance_pool_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceListResult"] + resource_group_name: str, + instance_pool_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceListResult"]: """Gets a list of all managed instances in an instance pool. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -65,7 +425,8 @@ def list_by_instance_pool( :param expand: The child resources to include in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceListResult or the result of cls(response) + :return: An iterator like instance of either ManagedInstanceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -74,38 +435,35 @@ def list_by_instance_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_instance_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,23 +481,25 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances'} # type: ignore + @distributed_trace def list( self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceListResult"] + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceListResult"]: """Gets a list of all managed instances in the subscription. :param expand: The child resources to include in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceListResult or the result of cls(response) + :return: An iterator like instance of either ManagedInstanceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -148,36 +508,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -195,18 +550,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedInstanceListResult"] + resource_group_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceListResult"]: """Gets a list of managed instances in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -215,7 +571,8 @@ def list_by_resource_group( :param expand: The child resources to include in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceListResult or the result of cls(response) + :return: An iterator like instance of either ManagedInstanceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -224,37 +581,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedInstanceListResult', pipeline_response) + deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -272,19 +625,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedInstance" + resource_group_name: str, + managed_instance_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.ManagedInstance": """Gets a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -304,29 +658,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -340,47 +683,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - parameters, # type: "_models.ManagedInstance" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstance"] + resource_group_name: str, + managed_instance_name: str, + parameters: "_models.ManagedInstance", + **kwargs: Any + ) -> Optional["_models.ManagedInstance"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstance"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstance') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstance') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -399,16 +733,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - parameters, # type: "_models.ManagedInstance" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstance"] + resource_group_name: str, + managed_instance_name: str, + parameters: "_models.ManagedInstance", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstance"]: """Creates or updates a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -420,15 +756,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstance :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. + :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 ManagedInstance or the result of cls(response) + :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 ManagedInstance or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstance"] lro_delay = kwargs.pop( 'polling_interval', @@ -440,27 +780,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstance', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -472,39 +806,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,13 +843,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -533,15 +860,17 @@ def begin_delete( :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -555,21 +884,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -581,47 +903,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - parameters, # type: "_models.ManagedInstanceUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedInstance"] + resource_group_name: str, + managed_instance_name: str, + parameters: "_models.ManagedInstanceUpdate", + **kwargs: Any + ) -> Optional["_models.ManagedInstance"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedInstance"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedInstanceUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedInstanceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -637,16 +949,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - parameters, # type: "_models.ManagedInstanceUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedInstance"] + resource_group_name: str, + managed_instance_name: str, + parameters: "_models.ManagedInstanceUpdate", + **kwargs: Any + ) -> LROPoller["_models.ManagedInstance"]: """Updates a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -658,15 +972,19 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate :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. + :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 ManagedInstance or the result of cls(response) + :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 ManagedInstance or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedInstance"] lro_delay = kwargs.pop( 'polling_interval', @@ -678,27 +996,21 @@ def begin_update( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedInstance', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -710,22 +1022,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}'} # type: ignore + @distributed_trace def list_by_managed_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - number_of_queries=None, # type: Optional[int] - databases=None, # type: Optional[str] - start_time=None, # type: Optional[str] - end_time=None, # type: Optional[str] - interval=None, # type: Optional[Union[str, "_models.QueryTimeGrainType"]] - aggregation_function=None, # type: Optional[Union[str, "_models.AggregationFunctionType"]] - observation_metric=None, # type: Optional[Union[str, "_models.MetricType"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TopQueriesListResult"] + resource_group_name: str, + managed_instance_name: str, + number_of_queries: Optional[int] = None, + databases: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, "_models.QueryTimeGrainType"]] = None, + aggregation_function: Optional[Union[str, "_models.AggregationFunctionType"]] = None, + observation_metric: Optional[Union[str, "_models.MetricType"]] = None, + **kwargs: Any + ) -> Iterable["_models.TopQueriesListResult"]: """Get top resource consuming queries of a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -750,7 +1063,8 @@ def list_by_managed_instance( :param observation_metric: Metric to be used for ranking top queries. Default is 'cpu'. :type observation_metric: str or ~azure.mgmt.sql.models.MetricType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopQueriesListResult or the result of cls(response) + :return: An iterator like instance of either TopQueriesListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.TopQueriesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -759,50 +1073,47 @@ def list_by_managed_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_managed_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if number_of_queries is not None: - query_parameters['numberOfQueries'] = self._serialize.query("number_of_queries", number_of_queries, 'int') - if databases is not None: - query_parameters['databases'] = self._serialize.query("databases", databases, 'str') - if start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - if end_time is not None: - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'str') - if aggregation_function is not None: - query_parameters['aggregationFunction'] = self._serialize.query("aggregation_function", aggregation_function, 'str') - if observation_metric is not None: - query_parameters['observationMetric'] = self._serialize.query("observation_metric", observation_metric, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + number_of_queries=number_of_queries, + databases=databases, + start_time=start_time, + end_time=end_time, + interval=interval, + aggregation_function=aggregation_function, + observation_metric=observation_metric, + template_url=self.list_by_managed_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + number_of_queries=number_of_queries, + databases=databases, + start_time=start_time, + end_time=end_time, + interval=interval, + aggregation_function=aggregation_function, + observation_metric=observation_metric, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TopQueriesListResult', pipeline_response) + deserialized = self._deserialize("TopQueriesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -820,6 +1131,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -827,38 +1139,28 @@ def get_next(next_link=None): def _failover_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - replica_type=None, # type: Optional[Union[str, "_models.ReplicaType"]] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + managed_instance_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if replica_type is not None: - query_parameters['replicaType'] = self._serialize.query("replica_type", replica_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -871,14 +1173,15 @@ def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover'} # type: ignore + + @distributed_trace def begin_failover( self, - resource_group_name, # type: str - managed_instance_name, # type: str - replica_type=None, # type: Optional[Union[str, "_models.ReplicaType"]] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + managed_instance_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + **kwargs: Any + ) -> LROPoller[None]: """Failovers a managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -890,15 +1193,17 @@ def begin_failover( :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -913,21 +1218,14 @@ def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -939,4 +1237,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py index f67995648e8d3..8caa47f905c86 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py @@ -5,25 +5,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "restorableDroppedDatabaseId": _SERIALIZER.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "restorableDroppedDatabaseId": _SERIALIZER.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "restorableDroppedDatabaseId": _SERIALIZER.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), + "policyName": _SERIALIZER.url("policy_name", policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_restorable_dropped_database_request( + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "restorableDroppedDatabaseId": _SERIALIZER.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations(object): """ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations operations. @@ -47,15 +222,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - restorable_dropped_database_id, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedBackupShortTermRetentionPolicy" + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + **kwargs: Any + ) -> "_models.ManagedBackupShortTermRetentionPolicy": """Gets a dropped database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,29 +252,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,51 +278,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - restorable_dropped_database_id, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedBackupShortTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,18 +329,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - restorable_dropped_database_id, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"]: """Sets a database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -200,15 +358,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedBackupShortTermRetentionPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -222,29 +385,21 @@ def begin_create_or_update( restorable_dropped_database_id=restorable_dropped_database_id, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,51 +411,41 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - restorable_dropped_database_id, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> Optional["_models.ManagedBackupShortTermRetentionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedBackupShortTermRetentionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedBackupShortTermRetentionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,18 +461,20 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - restorable_dropped_database_id, # type: str - policy_name, # type: Union[str, "_models.ManagedShortTermRetentionPolicyName"] - parameters, # type: "_models.ManagedBackupShortTermRetentionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"] + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, "_models.ManagedShortTermRetentionPolicyName"], + parameters: "_models.ManagedBackupShortTermRetentionPolicy", + **kwargs: Any + ) -> LROPoller["_models.ManagedBackupShortTermRetentionPolicy"]: """Sets a database's short term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -343,15 +490,20 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy :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. + :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 ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :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 ManagedBackupShortTermRetentionPolicy or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -365,29 +517,21 @@ def begin_update( restorable_dropped_database_id=restorable_dropped_database_id, policy_name=policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'policyName': self._serialize.url("policy_name", policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -399,16 +543,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'} # type: ignore + @distributed_trace def list_by_restorable_dropped_database( self, - resource_group_name, # type: str - managed_instance_name, # type: str - restorable_dropped_database_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedBackupShortTermRetentionPolicyListResult"] + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + **kwargs: Any + ) -> Iterable["_models.ManagedBackupShortTermRetentionPolicyListResult"]: """Gets a dropped database's short term retention policy list. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -419,8 +564,10 @@ def list_by_restorable_dropped_database( :param restorable_dropped_database_id: :type restorable_dropped_database_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] + :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicyListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedBackupShortTermRetentionPolicyListResult"] @@ -428,37 +575,35 @@ def list_by_restorable_dropped_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_restorable_dropped_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_restorable_dropped_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=self.list_by_restorable_dropped_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_restorable_dropped_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedBackupShortTermRetentionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -476,6 +621,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py index 4291625319759..9dedaaa35c75b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py @@ -5,25 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagedServerSecurityAlertPoliciesOperations(object): """ManagedServerSecurityAlertPoliciesOperations operations. @@ -47,14 +168,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagedServerSecurityAlertPolicy" + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + **kwargs: Any + ) -> "_models.ManagedServerSecurityAlertPolicy": """Get a managed server's threat detection policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +195,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +220,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - managed_instance_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - parameters, # type: "_models.ManagedServerSecurityAlertPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ManagedServerSecurityAlertPolicy"] + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: "_models.ManagedServerSecurityAlertPolicy", + **kwargs: Any + ) -> Optional["_models.ManagedServerSecurityAlertPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedServerSecurityAlertPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagedServerSecurityAlertPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagedServerSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,17 +269,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - parameters, # type: "_models.ManagedServerSecurityAlertPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ManagedServerSecurityAlertPolicy"] + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: "_models.ManagedServerSecurityAlertPolicy", + **kwargs: Any + ) -> LROPoller["_models.ManagedServerSecurityAlertPolicy"]: """Creates or updates a threat detection policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -191,15 +295,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy :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. + :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 ManagedServerSecurityAlertPolicy or the result of cls(response) + :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 ManagedServerSecurityAlertPolicy or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedServerSecurityAlertPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -212,28 +320,21 @@ def begin_create_or_update( managed_instance_name=managed_instance_name, security_alert_policy_name=security_alert_policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ManagedServerSecurityAlertPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -245,15 +346,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagedServerSecurityAlertPolicyListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ManagedServerSecurityAlertPolicyListResult"]: """Get the managed server's threat detection policies. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -262,8 +364,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedServerSecurityAlertPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicyListResult] + :return: An iterator like instance of either ManagedServerSecurityAlertPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedServerSecurityAlertPolicyListResult"] @@ -271,36 +375,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagedServerSecurityAlertPolicyListResult', pipeline_response) + deserialized = self._deserialize("ManagedServerSecurityAlertPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -318,6 +419,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations.py index 1f3c60407aa41..a729ae8de2248 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Sql/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available SQL Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +127,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations_health_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations_health_operations.py deleted file mode 100644 index 5ff60f1ff971e..0000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations_health_operations.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class OperationsHealthOperations(object): - """OperationsHealthOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.sql.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_location( - self, - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsHealthListResult"] - """Gets a service operation health status. - - :param location_name: The name of the region where the resource is located. - :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsHealthListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OperationsHealthListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsHealthListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsHealthListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/operationsHealth'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py index b1e163f03fd04..508db37166496 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class OutboundFirewallRulesOperations(object): """OutboundFirewallRulesOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - outbound_rule_fqdn, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OutboundFirewallRule" + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + **kwargs: Any + ) -> "_models.OutboundFirewallRule": """Gets an outbound firewall rule. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - outbound_rule_fqdn, # type: str - parameters, # type: "_models.OutboundFirewallRule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OutboundFirewallRule"] + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + parameters: "_models.OutboundFirewallRule", + **kwargs: Any + ) -> Optional["_models.OutboundFirewallRule"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundFirewallRule"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'OutboundFirewallRule') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OutboundFirewallRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +303,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - outbound_rule_fqdn, # type: str - parameters, # type: "_models.OutboundFirewallRule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OutboundFirewallRule"] + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + parameters: "_models.OutboundFirewallRule", + **kwargs: Any + ) -> LROPoller["_models.OutboundFirewallRule"]: """Create a outbound firewall rule with a given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -194,15 +329,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule :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. + :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 OutboundFirewallRule or the result of cls(response) + :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 OutboundFirewallRule or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundFirewallRule"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,28 +354,21 @@ def begin_create_or_update( server_name=server_name, outbound_rule_fqdn=outbound_rule_fqdn, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OutboundFirewallRule', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -248,41 +380,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - outbound_rule_fqdn, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,14 +419,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - outbound_rule_fqdn, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + outbound_rule_fqdn: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a outbound firewall rule with a given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -314,15 +439,17 @@ def begin_delete( :type outbound_rule_fqdn: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -337,22 +464,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'outboundRuleFqdn': self._serialize.url("outbound_rule_fqdn", outbound_rule_fqdn, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -364,15 +483,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OutboundFirewallRuleListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.OutboundFirewallRuleListResult"]: """Gets all outbound firewall rules on a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -381,7 +501,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OutboundFirewallRuleListResult or the result of cls(response) + :return: An iterator like instance of either OutboundFirewallRuleListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OutboundFirewallRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -390,36 +511,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OutboundFirewallRuleListResult', pipeline_response) + deserialized = self._deserialize("OutboundFirewallRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,6 +555,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_endpoint_connections_operations.py index 5914e273aba76..4f9cb02b5c585 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_endpoint_connections_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_endpoint_connections_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets a private endpoint connection. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,17 +300,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -191,15 +326,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection :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. + :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 PrivateEndpointConnection or the result of cls(response) + :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 PrivateEndpointConnection or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -212,28 +351,21 @@ def begin_create_or_update( server_name=server_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -245,41 +377,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -292,14 +416,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -311,15 +436,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -334,22 +461,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -361,15 +480,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: """Gets all private endpoint connections on a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -378,8 +498,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -387,36 +509,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -434,6 +553,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_link_resources_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_link_resources_operations.py index fb0f3abf225ab..86b6b723ed1dc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_link_resources_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_link_resources_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources/{groupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "groupName": _SERIALIZER.url("group_name", group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateLinkResourceListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateLinkResourceListResult"]: """Gets the private link resources for SQL server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,7 +134,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,36 +144,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,19 +188,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResource" + resource_group_name: str, + server_name: str, + group_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResource": """Gets a private link resource for SQL server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,28 +221,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,4 +246,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py index 1ddd442e44ce3..6e82a92c3d647 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py @@ -5,22 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class RecommendedSensitivityLabelsOperations(object): """RecommendedSensitivityLabelsOperations operations. @@ -44,15 +91,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.RecommendedSensitivityLabelUpdateList" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.RecommendedSensitivityLabelUpdateList", + **kwargs: Any + ) -> None: """Update recommended sensitivity labels states of a given database using an operations batch. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,31 +121,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,3 +149,4 @@ def update( return cls(pipeline_response, None, {}) update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py index 9b5db207ccdeb..f5d1157ced353 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_get_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RecoverableDatabasesOperations(object): """RecoverableDatabasesOperations operations. @@ -45,14 +119,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RecoverableDatabase" + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.RecoverableDatabase": """Gets a recoverable database, which is a resource representing a database's geo backup. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,28 +146,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,15 +171,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}'} # type: ignore + + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecoverableDatabaseListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.RecoverableDatabaseListResult"]: """Gets a list of recoverable databases. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -124,7 +190,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RecoverableDatabaseListResult or the result of cls(response) + :return: An iterator like instance of either RecoverableDatabaseListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RecoverableDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -133,36 +200,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RecoverableDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RecoverableDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,6 +244,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_managed_databases_operations.py index 3c7bc6d261938..6242cf0c08a2e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_managed_databases_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + recoverable_database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "recoverableDatabaseName": _SERIALIZER.url("recoverable_database_name", recoverable_database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RecoverableManagedDatabasesOperations(object): """RecoverableManagedDatabasesOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecoverableManagedDatabaseListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.RecoverableManagedDatabaseListResult"]: """Gets a list of recoverable managed databases. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,8 +134,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RecoverableManagedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabaseListResult] + :return: An iterator like instance of either RecoverableManagedDatabaseListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoverableManagedDatabaseListResult"] @@ -69,36 +145,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RecoverableManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RecoverableManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,19 +189,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - recoverable_database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RecoverableManagedDatabase" + resource_group_name: str, + managed_instance_name: str, + recoverable_database_name: str, + **kwargs: Any + ) -> "_models.RecoverableManagedDatabase": """Gets a recoverable managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,28 +222,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'recoverableDatabaseName': self._serialize.url("recoverable_database_name", recoverable_database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + recoverable_database_name=recoverable_database_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,4 +247,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py index 6484663208189..c1c823bf05f33 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py @@ -5,25 +5,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "linkId": _SERIALIZER.url("link_id", link_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_failover_request_initial( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "linkId": _SERIALIZER.url("link_id", link_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_failover_allow_data_loss_request_initial( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "linkId": _SERIALIZER.url("link_id", link_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_unlink_request_initial( + subscription_id: str, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "linkId": _SERIALIZER.url("link_id", link_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "linkId": _SERIALIZER.url("link_id", link_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/replicationLinks') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ReplicationLinksOperations(object): """ReplicationLinksOperations operations. @@ -47,15 +306,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any + ) -> None: """Deletes a database replication link. Cannot be done during failover. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,27 +336,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,41 +361,33 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}'} # type: ignore + def _failover_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self._failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + template_url=self._failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -157,15 +400,16 @@ def _failover_initial( _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover'} # type: ignore + + @distributed_trace def begin_failover( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any + ) -> LROPoller[None]: """Sets which replica database is primary by failing over from the current primary replica database. @@ -180,15 +424,17 @@ def begin_failover( :type link_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -204,23 +450,14 @@ def begin_failover( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -232,43 +469,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover'} # type: ignore def _failover_allow_data_loss_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self._failover_allow_data_loss_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_failover_allow_data_loss_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + template_url=self._failover_allow_data_loss_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,15 +510,16 @@ def _failover_allow_data_loss_initial( _failover_allow_data_loss_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss'} # type: ignore + + @distributed_trace def begin_failover_allow_data_loss( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any + ) -> LROPoller[None]: """Sets which replica database is primary by failing over from the current primary replica database. This operation might result in data loss. @@ -304,15 +534,17 @@ def begin_failover_allow_data_loss( :type link_id: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -328,23 +560,14 @@ def begin_failover_allow_data_loss( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -356,49 +579,41 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover_allow_data_loss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss'} # type: ignore def _unlink_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - parameters, # type: "_models.UnlinkParameters" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: "_models.UnlinkParameters", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._unlink_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'UnlinkParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_unlink_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + content_type=content_type, + json=_json, + template_url=self._unlink_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UnlinkParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -411,16 +626,17 @@ def _unlink_initial( _unlink_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink'} # type: ignore + + @distributed_trace def begin_unlink( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - parameters, # type: "_models.UnlinkParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: "_models.UnlinkParameters", + **kwargs: Any + ) -> LROPoller[None]: """Deletes a database replication link in forced or friendly way. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -436,15 +652,18 @@ def begin_unlink( :type parameters: ~azure.mgmt.sql.models.UnlinkParameters :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -458,26 +677,18 @@ def begin_unlink( database_name=database_name, link_id=link_id, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -489,16 +700,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_unlink.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReplicationLinkListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.ReplicationLinkListResult"]: """Gets a list of replication links on database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -509,7 +721,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationLinkListResult or the result of cls(response) + :return: An iterator like instance of either ReplicationLinkListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ReplicationLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -518,37 +731,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReplicationLinkListResult', pipeline_response) + deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -566,20 +777,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - link_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ReplicationLink" + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + **kwargs: Any + ) -> "_models.ReplicationLink": """Gets a replication link. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -601,29 +813,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'linkId': self._serialize.url("link_id", link_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -637,15 +839,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}'} # type: ignore + + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReplicationLinkListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ReplicationLinkListResult"]: """Gets a list of replication links. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -654,7 +858,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationLinkListResult or the result of cls(response) + :return: An iterator like instance of either ReplicationLinkListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ReplicationLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -663,36 +868,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReplicationLinkListResult', pipeline_response) + deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -710,6 +912,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py index f219d90bfec44..a2f33c7ad4283 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + restorable_dropped_database_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "restorableDroppedDatabaseId": _SERIALIZER.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableDroppedDatabasesOperations(object): """RestorableDroppedDatabasesOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableDroppedDatabaseListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.RestorableDroppedDatabaseListResult"]: """Gets a list of restorable dropped databases. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,8 +134,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDroppedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabaseListResult] + :return: An iterator like instance of either RestorableDroppedDatabaseListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedDatabaseListResult"] @@ -69,36 +145,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDroppedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RestorableDroppedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,19 +189,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - restorable_dropped_database_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RestorableDroppedDatabase" + resource_group_name: str, + server_name: str, + restorable_dropped_database_id: str, + **kwargs: Any + ) -> "_models.RestorableDroppedDatabase": """Gets a restorable dropped database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,28 +222,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,4 +247,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py index 80ff10df5a50d..7a17d8153f9f3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "restorableDroppedDatabaseId": _SERIALIZER.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableDroppedManagedDatabasesOperations(object): """RestorableDroppedManagedDatabasesOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableDroppedManagedDatabaseListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.RestorableDroppedManagedDatabaseListResult"]: """Gets a list of restorable dropped managed databases. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,8 +134,10 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDroppedManagedDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabaseListResult] + :return: An iterator like instance of either RestorableDroppedManagedDatabaseListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedManagedDatabaseListResult"] @@ -69,36 +145,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDroppedManagedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("RestorableDroppedManagedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,19 +189,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - restorable_dropped_database_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RestorableDroppedManagedDatabase" + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + **kwargs: Any + ) -> "_models.RestorableDroppedManagedDatabase": """Gets a restorable dropped managed database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,28 +222,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'restorableDroppedDatabaseId': self._serialize.url("restorable_dropped_database_id", restorable_dropped_database_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,4 +247,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py index c7a009cd362f5..d766a4bed2eda 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py @@ -5,25 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + restore_point_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + restore_point_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class RestorePointsOperations(object): """RestorePointsOperations operations. @@ -47,14 +205,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorePointListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.RestorePointListResult"]: """Gets a list of database restore points. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -65,7 +223,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorePointListResult or the result of cls(response) + :return: An iterator like instance of either RestorePointListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorePointListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -74,37 +233,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorePointListResult', pipeline_response) + deserialized = self._deserialize("RestorePointListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,6 +279,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -129,45 +287,34 @@ def get_next(next_link=None): def _create_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.CreateDatabaseRestorePointDefinition" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RestorePoint"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.CreateDatabaseRestorePointDefinition", + **kwargs: Any + ) -> Optional["_models.RestorePoint"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RestorePoint"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'CreateDatabaseRestorePointDefinition') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CreateDatabaseRestorePointDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -186,17 +333,19 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.CreateDatabaseRestorePointDefinition" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.RestorePoint"] + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.CreateDatabaseRestorePointDefinition", + **kwargs: Any + ) -> LROPoller["_models.RestorePoint"]: """Creates a restore point for a data warehouse. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -210,15 +359,19 @@ def begin_create( :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition :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. + :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 RestorePoint or the result of cls(response) + :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 RestorePoint or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -231,28 +384,21 @@ def begin_create( server_name=server_name, database_name=database_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('RestorePoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -264,17 +410,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - restore_point_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RestorePoint" + resource_group_name: str, + server_name: str, + database_name: str, + restore_point_name: str, + **kwargs: Any + ) -> "_models.RestorePoint": """Gets a restore point. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -296,29 +443,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'restorePointName': self._serialize.url("restore_point_name", restore_point_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -332,17 +469,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - restore_point_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + restore_point_name: str, + **kwargs: Any + ) -> None: """Deletes a restore point. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -364,27 +503,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'restorePointName': self._serialize.url("restore_point_name", restore_point_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -396,3 +527,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py index 45d9f13263c33..fde8179912624 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py @@ -5,23 +5,380 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_current_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + if count is not None: + query_parameters['$count'] = _SERIALIZER.query("count", count, 'bool') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_recommended_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + if include_disabled_recommendations is not None: + query_parameters['includeDisabledRecommendations'] = _SERIALIZER.query("include_disabled_recommendations", include_disabled_recommendations, 'bool') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_enable_recommendation_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + sensitivity_label_source = "recommended" + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_disable_recommendation_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + sensitivity_label_source = "recommended" + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + sensitivity_label_source: Union[str, "_models.SensitivityLabelSource"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + sensitivity_label_source = "current" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + sensitivity_label_source = "current" + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class SensitivityLabelsOperations(object): """SensitivityLabelsOperations operations. @@ -45,17 +402,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_current_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - skip_token=None, # type: Optional[str] - count=None, # type: Optional[bool] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SensitivityLabelListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SensitivityLabelListResult"]: """Gets the sensitivity labels of a given database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,7 +429,8 @@ def list_current_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -81,43 +439,41 @@ def list_current_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_current_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if count is not None: - query_parameters['$count'] = self._serialize.query("count", count, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + count=count, + filter=filter, + template_url=self.list_current_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_current_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + count=count, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -135,20 +491,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_current_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - parameters, # type: "_models.SensitivityLabelUpdateList" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + parameters: "_models.SensitivityLabelUpdateList", + **kwargs: Any + ) -> None: """Update sensitivity labels of a given database using an operations batch. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -170,31 +527,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'SensitivityLabelUpdateList') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabelUpdateList') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,17 +556,18 @@ def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels'} # type: ignore + + @distributed_trace def list_recommended_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - skip_token=None, # type: Optional[str] - include_disabled_recommendations=None, # type: Optional[bool] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SensitivityLabelListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SensitivityLabelListResult"]: """Gets the sensitivity labels of a given database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -235,7 +585,8 @@ def list_recommended_by_database( :param filter: An OData filter expression that filters elements in the collection. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of cls(response) + :return: An iterator like instance of either SensitivityLabelListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabelListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -244,43 +595,41 @@ def list_recommended_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_recommended_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - if include_disabled_recommendations is not None: - query_parameters['includeDisabledRecommendations'] = self._serialize.query("include_disabled_recommendations", include_disabled_recommendations, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=self.list_recommended_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_recommended_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SensitivityLabelListResult', pipeline_response) + deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -298,22 +647,23 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_recommended_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels'} # type: ignore + @distributed_trace def enable_recommendation( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: """Enables sensitivity recommendations on a given column (recommendations are enabled by default on all columns). @@ -340,31 +690,21 @@ def enable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.enable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_enable_recommendation_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.enable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -377,17 +717,18 @@ def enable_recommendation( enable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable'} # type: ignore + + @distributed_trace def disable_recommendation( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: """Disables sensitivity recommendations on a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -413,31 +754,21 @@ def disable_recommendation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "recommended" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.disable_recommendation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_disable_recommendation_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.disable_recommendation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -450,18 +781,19 @@ def disable_recommendation( disable_recommendation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - sensitivity_label_source, # type: Union[str, "_models.SensitivityLabelSource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SensitivityLabel" + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + sensitivity_label_source: Union[str, "_models.SensitivityLabelSource"], + **kwargs: Any + ) -> "_models.SensitivityLabel": """Gets the sensitivity label of a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -489,32 +821,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + sensitivity_label_source=sensitivity_label_source, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -528,20 +850,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - parameters, # type: "_models.SensitivityLabel" - **kwargs # type: Any - ): - # type: (...) -> "_models.SensitivityLabel" + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: "_models.SensitivityLabel", + **kwargs: Any + ) -> "_models.SensitivityLabel": """Creates or updates the sensitivity label of a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -569,38 +893,26 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SensitivityLabel') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SensitivityLabel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -618,19 +930,21 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - schema_name, # type: str - table_name, # type: str - column_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: """Deletes the sensitivity label of a given column. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -656,31 +970,21 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - sensitivity_label_source = "current" - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'schemaName': self._serialize.url("schema_name", schema_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - 'columnName': self._serialize.url("column_name", column_name, 'str'), - 'sensitivityLabelSource': self._serialize.url("sensitivity_label_source", sensitivity_label_source, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -692,3 +996,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py index 04d286963c72c..6ec3d65e1f800 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py @@ -5,22 +5,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + advisor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + server_name: str, + advisor_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ServerAdvisorsOperations(object): """ServerAdvisorsOperations operations. @@ -44,14 +169,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> List["_models.Advisor"] + resource_group_name: str, + server_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> List["_models.Advisor"]: """Gets a list of server advisors. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,29 +196,18 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,16 +221,18 @@ def list_by_server( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - advisor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Advisor" + resource_group_name: str, + server_name: str, + advisor_name: str, + **kwargs: Any + ) -> "_models.Advisor": """Gets a server advisor. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -136,28 +252,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -171,17 +277,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - server_name, # type: str - advisor_name, # type: str - parameters, # type: "_models.Advisor" - **kwargs # type: Any - ): - # type: (...) -> "_models.Advisor" + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: "_models.Advisor", + **kwargs: Any + ) -> "_models.Advisor": """Updates a server advisor. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -203,33 +311,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'advisorName': self._serialize.url("advisor_name", advisor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Advisor') + + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Advisor') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,4 +341,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py index 2d236c3e7c4dc..1dafb35c8431a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py @@ -5,22 +5,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ServerAutomaticTuningOperations(object): """ServerAutomaticTuningOperations operations. @@ -44,13 +126,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerAutomaticTuning" + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> "_models.ServerAutomaticTuning": """Retrieves server automatic tuning options. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -68,27 +150,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,16 +174,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ServerAutomaticTuning" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerAutomaticTuning" + resource_group_name: str, + server_name: str, + parameters: "_models.ServerAutomaticTuning", + **kwargs: Any + ) -> "_models.ServerAutomaticTuning": """Update automatic tuning options on server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -131,32 +205,22 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerAutomaticTuning') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerAutomaticTuning') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,4 +234,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py index 979ea6202598a..3a59660b19f73 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerAzureADAdministratorsOperations(object): """ServerAzureADAdministratorsOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerAzureADAdministrator" + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> "_models.ServerAzureADAdministrator": """Gets a Azure Active Directory administrator. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - parameters, # type: "_models.ServerAzureADAdministrator" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerAzureADAdministrator"] + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: "_models.ServerAzureADAdministrator", + **kwargs: Any + ) -> Optional["_models.ServerAzureADAdministrator"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerAzureADAdministrator"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerAzureADAdministrator') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerAzureADAdministrator') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +303,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - parameters, # type: "_models.ServerAzureADAdministrator" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerAzureADAdministrator"] + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: "_models.ServerAzureADAdministrator", + **kwargs: Any + ) -> LROPoller["_models.ServerAzureADAdministrator"]: """Creates or updates an existing Azure Active Directory administrator. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -194,15 +329,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator :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. + :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 ServerAzureADAdministrator or the result of cls(response) + :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 ServerAzureADAdministrator or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerAzureADAdministrator"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,28 +354,21 @@ def begin_create_or_update( server_name=server_name, administrator_name=administrator_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerAzureADAdministrator', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -248,41 +380,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,14 +419,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - administrator_name, # type: Union[str, "_models.AdministratorName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> LROPoller[None]: """Deletes the Azure Active Directory administrator with the given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -314,15 +439,17 @@ def begin_delete( :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -337,22 +464,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("administrator_name", administrator_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -364,15 +483,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AdministratorListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.AdministratorListResult"]: """Gets a list of Azure Active Directory administrators in a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -381,7 +501,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AdministratorListResult or the result of cls(response) + :return: An iterator like instance of either AdministratorListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.AdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -390,36 +511,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AdministratorListResult', pipeline_response) + deserialized = self._deserialize("AdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,6 +555,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_only_authentications_operations.py index d4c26b1e4a37b..9fd48977482e7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_only_authentications_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_only_authentications_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerAzureADOnlyAuthenticationsOperations(object): """ServerAzureADOnlyAuthenticationsOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerAzureADOnlyAuthentication" + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + **kwargs: Any + ) -> "_models.ServerAzureADOnlyAuthentication": """Gets a specific Azure Active Directory only authentication property. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - parameters, # type: "_models.ServerAzureADOnlyAuthentication" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerAzureADOnlyAuthentication"] + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + parameters: "_models.ServerAzureADOnlyAuthentication", + **kwargs: Any + ) -> Optional["_models.ServerAzureADOnlyAuthentication"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerAzureADOnlyAuthentication"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerAzureADOnlyAuthentication') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerAzureADOnlyAuthentication') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +303,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - parameters, # type: "_models.ServerAzureADOnlyAuthentication" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerAzureADOnlyAuthentication"] + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + parameters: "_models.ServerAzureADOnlyAuthentication", + **kwargs: Any + ) -> LROPoller["_models.ServerAzureADOnlyAuthentication"]: """Sets Server Active Directory only authentication property or updates an existing server Active Directory only authentication property. @@ -196,15 +331,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication :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. + :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 ServerAzureADOnlyAuthentication or the result of cls(response) + :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 ServerAzureADOnlyAuthentication or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerAzureADOnlyAuthentication"] lro_delay = kwargs.pop( 'polling_interval', @@ -217,28 +356,21 @@ def begin_create_or_update( server_name=server_name, authentication_name=authentication_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerAzureADOnlyAuthentication', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -250,41 +382,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -297,14 +421,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - authentication_name, # type: Union[str, "_models.AuthenticationName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + authentication_name: Union[str, "_models.AuthenticationName"], + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing server Active Directory only authentication property. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -316,15 +441,17 @@ def begin_delete( :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -339,22 +466,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'authenticationName': self._serialize.url("authentication_name", authentication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -366,15 +485,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AzureADOnlyAuthListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.AzureADOnlyAuthListResult"]: """Gets a list of server Azure Active Directory only authentications. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -383,7 +503,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureADOnlyAuthListResult or the result of cls(response) + :return: An iterator like instance of either AzureADOnlyAuthListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.AzureADOnlyAuthListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -392,36 +513,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AzureADOnlyAuthListResult', pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -439,6 +557,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_blob_auditing_policies_operations.py index 5eaa202c79ff7..63d53d06511e2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_blob_auditing_policies_operations.py @@ -5,25 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + blob_auditing_policy_name = "default" + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerBlobAuditingPoliciesOperations(object): """ServerBlobAuditingPoliciesOperations operations. @@ -47,13 +168,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerBlobAuditingPolicy" + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> "_models.ServerBlobAuditingPolicy": """Gets a server's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,29 +192,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,49 +216,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ServerBlobAuditingPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerBlobAuditingPolicy"] + resource_group_name: str, + server_name: str, + parameters: "_models.ServerBlobAuditingPolicy", + **kwargs: Any + ) -> Optional["_models.ServerBlobAuditingPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerBlobAuditingPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - blob_auditing_policy_name = "default" - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerBlobAuditingPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerBlobAuditingPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,16 +263,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ServerBlobAuditingPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerBlobAuditingPolicy"] + resource_group_name: str, + server_name: str, + parameters: "_models.ServerBlobAuditingPolicy", + **kwargs: Any + ) -> LROPoller["_models.ServerBlobAuditingPolicy"]: """Creates or updates a server's blob auditing policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -186,15 +286,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy :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. + :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 ServerBlobAuditingPolicy or the result of cls(response) + :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 ServerBlobAuditingPolicy or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -206,29 +310,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerBlobAuditingPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - blob_auditing_policy_name = "default" - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'blobAuditingPolicyName': self._serialize.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -240,15 +336,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerBlobAuditingPolicyListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerBlobAuditingPolicyListResult"]: """Lists auditing settings of a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -257,7 +354,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerBlobAuditingPolicyListResult or the result of cls(response) + :return: An iterator like instance of either ServerBlobAuditingPolicyListResult or the result + of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerBlobAuditingPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -266,36 +364,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerBlobAuditingPolicyListResult', pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -313,6 +408,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py index bbc379ec28b55..f937ba75b59fc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + communication_link_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "communicationLinkName": _SERIALIZER.url("communication_link_name", communication_link_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + communication_link_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "communicationLinkName": _SERIALIZER.url("communication_link_name", communication_link_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + server_name: str, + communication_link_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "communicationLinkName": _SERIALIZER.url("communication_link_name", communication_link_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_server_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerCommunicationLinksOperations(object): """ServerCommunicationLinksOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - communication_link_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + communication_link_name: str, + **kwargs: Any + ) -> None: """Deletes a server communication link. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,26 +226,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + communication_link_name=communication_link_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,14 +250,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - communication_link_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerCommunicationLink" + resource_group_name: str, + server_name: str, + communication_link_name: str, + **kwargs: Any + ) -> "_models.ServerCommunicationLink": """Returns a server communication link. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -133,28 +278,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + communication_link_name=communication_link_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,49 +303,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - communication_link_name, # type: str - parameters, # type: "_models.ServerCommunicationLink" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerCommunicationLink"] + resource_group_name: str, + server_name: str, + communication_link_name: str, + parameters: "_models.ServerCommunicationLink", + **kwargs: Any + ) -> Optional["_models.ServerCommunicationLink"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerCommunicationLink"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerCommunicationLink') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + communication_link_name=communication_link_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerCommunicationLink') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -226,17 +352,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - communication_link_name, # type: str - parameters, # type: "_models.ServerCommunicationLink" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerCommunicationLink"] + resource_group_name: str, + server_name: str, + communication_link_name: str, + parameters: "_models.ServerCommunicationLink", + **kwargs: Any + ) -> LROPoller["_models.ServerCommunicationLink"]: """Creates a server communication link. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -250,15 +378,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink :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. + :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 ServerCommunicationLink or the result of cls(response) + :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 ServerCommunicationLink or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerCommunicationLink"] lro_delay = kwargs.pop( 'polling_interval', @@ -271,28 +403,21 @@ def begin_create_or_update( server_name=server_name, communication_link_name=communication_link_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerCommunicationLink', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'communicationLinkName': self._serialize.url("communication_link_name", communication_link_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -304,15 +429,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerCommunicationLinkListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerCommunicationLinkListResult"]: """Gets a list of server communication links. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -321,7 +447,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerCommunicationLinkListResult or the result of cls(response) + :return: An iterator like instance of either ServerCommunicationLinkListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerCommunicationLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -330,36 +457,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerCommunicationLinkListResult', pipeline_response) + deserialized = self._deserialize("ServerCommunicationLinkListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -377,6 +501,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py index ff6464887389d..a8be89f6a39b0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py @@ -5,25 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerConnectionPoliciesOperations(object): """ServerConnectionPoliciesOperations operations. @@ -47,14 +168,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - connection_policy_name, # type: Union[str, "_models.ConnectionPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerConnectionPolicy" + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + **kwargs: Any + ) -> "_models.ServerConnectionPolicy": """Gets a server connection policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +195,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +220,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - connection_policy_name, # type: Union[str, "_models.ConnectionPolicyName"] - parameters, # type: "_models.ServerConnectionPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerConnectionPolicy"] + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + parameters: "_models.ServerConnectionPolicy", + **kwargs: Any + ) -> Optional["_models.ServerConnectionPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerConnectionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerConnectionPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerConnectionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,17 +269,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - connection_policy_name, # type: Union[str, "_models.ConnectionPolicyName"] - parameters, # type: "_models.ServerConnectionPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerConnectionPolicy"] + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + parameters: "_models.ServerConnectionPolicy", + **kwargs: Any + ) -> LROPoller["_models.ServerConnectionPolicy"]: """Updates a server connection policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -191,15 +295,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ServerConnectionPolicy or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServerConnectionPolicy or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -212,28 +320,21 @@ def begin_create_or_update( server_name=server_name, connection_policy_name=connection_policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -245,15 +346,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerConnectionPolicyListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerConnectionPolicyListResult"]: """Lists connection policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -262,7 +364,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerConnectionPolicyListResult or the result of cls(response) + :return: An iterator like instance of either ServerConnectionPolicyListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -271,36 +374,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerConnectionPolicyListResult', pipeline_response) + deserialized = self._deserialize("ServerConnectionPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -318,6 +418,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dev_ops_audit_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dev_ops_audit_settings_operations.py index b78c42b5ed767..a0a389f37a0a9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dev_ops_audit_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dev_ops_audit_settings_operations.py @@ -5,25 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "devOpsAuditingSettingsName": _SERIALIZER.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "devOpsAuditingSettingsName": _SERIALIZER.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerDevOpsAuditSettingsOperations(object): """ServerDevOpsAuditSettingsOperations operations. @@ -47,14 +168,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - dev_ops_auditing_settings_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerDevOpsAuditingSettings" + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: str, + **kwargs: Any + ) -> "_models.ServerDevOpsAuditingSettings": """Gets a server's DevOps audit settings. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -75,28 +196,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'devOpsAuditingSettingsName': self._serialize.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,49 +221,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - dev_ops_auditing_settings_name, # type: str - parameters, # type: "_models.ServerDevOpsAuditingSettings" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerDevOpsAuditingSettings"] + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: str, + parameters: "_models.ServerDevOpsAuditingSettings", + **kwargs: Any + ) -> Optional["_models.ServerDevOpsAuditingSettings"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerDevOpsAuditingSettings"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'devOpsAuditingSettingsName': self._serialize.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerDevOpsAuditingSettings') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerDevOpsAuditingSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,17 +270,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - dev_ops_auditing_settings_name, # type: str - parameters, # type: "_models.ServerDevOpsAuditingSettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerDevOpsAuditingSettings"] + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: str, + parameters: "_models.ServerDevOpsAuditingSettings", + **kwargs: Any + ) -> LROPoller["_models.ServerDevOpsAuditingSettings"]: """Creates or updates a server's DevOps audit settings. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -193,15 +297,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings :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. + :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 ServerDevOpsAuditingSettings or the result of cls(response) + :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 ServerDevOpsAuditingSettings or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDevOpsAuditingSettings"] lro_delay = kwargs.pop( 'polling_interval', @@ -214,28 +322,21 @@ def begin_create_or_update( server_name=server_name, dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerDevOpsAuditingSettings', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'devOpsAuditingSettingsName': self._serialize.url("dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -247,15 +348,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerDevOpsAuditSettingsListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerDevOpsAuditSettingsListResult"]: """Lists DevOps audit settings of a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -264,8 +366,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerDevOpsAuditSettingsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditSettingsListResult] + :return: An iterator like instance of either ServerDevOpsAuditSettingsListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditSettingsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDevOpsAuditSettingsListResult"] @@ -273,36 +377,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerDevOpsAuditSettingsListResult', pipeline_response) + deserialized = self._deserialize("ServerDevOpsAuditSettingsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -320,6 +421,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dns_aliases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dns_aliases_operations.py index 50ee17b91fe55..e2fab2660e2c8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dns_aliases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dns_aliases_operations.py @@ -5,25 +5,214 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + dns_alias_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + dns_alias_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + dns_alias_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_acquire_request_initial( + resource_group_name: str, + server_name: str, + dns_alias_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ServerDnsAliasesOperations(object): """ServerDnsAliasesOperations operations. @@ -47,14 +236,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - dns_alias_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerDnsAlias" + resource_group_name: str, + server_name: str, + dns_alias_name: str, + **kwargs: Any + ) -> "_models.ServerDnsAlias": """Gets a server DNS alias. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +263,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,43 +288,34 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - dns_alias_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerDnsAlias"] + resource_group_name: str, + server_name: str, + dns_alias_name: str, + **kwargs: Any + ) -> Optional["_models.ServerDnsAlias"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerDnsAlias"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,16 +334,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - dns_alias_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerDnsAlias"] + resource_group_name: str, + server_name: str, + dns_alias_name: str, + **kwargs: Any + ) -> LROPoller["_models.ServerDnsAlias"]: """Creates a server DNS alias. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -185,15 +357,18 @@ def begin_create_or_update( :type dns_alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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 ServerDnsAlias or the result of cls(response) + :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 ServerDnsAlias or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDnsAlias"] lro_delay = kwargs.pop( 'polling_interval', @@ -208,25 +383,17 @@ def begin_create_or_update( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerDnsAlias', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -238,41 +405,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - dns_alias_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + dns_alias_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,14 +444,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - dns_alias_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + dns_alias_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the server DNS alias with the given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -304,15 +464,17 @@ def begin_delete( :type dns_alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -327,22 +489,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -354,15 +508,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerDnsAliasListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerDnsAliasListResult"]: """Gets a list of server DNS aliases for a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -371,7 +526,8 @@ def list_by_server( :param server_name: The name of the server that the alias is pointing to. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerDnsAliasListResult or the result of cls(response) + :return: An iterator like instance of either ServerDnsAliasListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDnsAliasListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -380,36 +536,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerDnsAliasListResult', pipeline_response) + deserialized = self._deserialize("ServerDnsAliasListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,6 +580,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -434,45 +588,34 @@ def get_next(next_link=None): def _acquire_initial( self, - resource_group_name, # type: str - server_name, # type: str - dns_alias_name, # type: str - parameters, # type: "_models.ServerDnsAliasAcquisition" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerDnsAlias"] + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: "_models.ServerDnsAliasAcquisition", + **kwargs: Any + ) -> Optional["_models.ServerDnsAlias"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerDnsAlias"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._acquire_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerDnsAliasAcquisition') + + request = build_acquire_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._acquire_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerDnsAliasAcquisition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -488,17 +631,19 @@ def _acquire_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _acquire_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire'} # type: ignore + + @distributed_trace def begin_acquire( self, - resource_group_name, # type: str - server_name, # type: str - dns_alias_name, # type: str - parameters, # type: "_models.ServerDnsAliasAcquisition" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerDnsAlias"] + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: "_models.ServerDnsAliasAcquisition", + **kwargs: Any + ) -> LROPoller["_models.ServerDnsAlias"]: """Acquires server DNS alias from another server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -512,15 +657,19 @@ def begin_acquire( :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition :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. + :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 ServerDnsAlias or the result of cls(response) + :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 ServerDnsAlias or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerDnsAlias"] lro_delay = kwargs.pop( 'polling_interval', @@ -533,28 +682,21 @@ def begin_acquire( server_name=server_name, dns_alias_name=dns_alias_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerDnsAlias', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'dnsAliasName': self._serialize.url("dns_alias_name", dns_alias_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -566,4 +708,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_acquire.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py index 104ca0fcd107e..a43a7c525eb15 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + key_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + key_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + key_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class ServerKeysOperations(object): """ServerKeysOperations operations. @@ -47,13 +199,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerKeyListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerKeyListResult"]: """Gets a list of server keys. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,36 +223,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerKeyListResult', pipeline_response) + deserialized = self._deserialize("ServerKeyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,19 +267,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerKey" + resource_group_name: str, + server_name: str, + key_name: str, + **kwargs: Any + ) -> "_models.ServerKey": """Gets a server key. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -150,28 +300,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,49 +325,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - key_name, # type: str - parameters, # type: "_models.ServerKey" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerKey"] + resource_group_name: str, + server_name: str, + key_name: str, + parameters: "_models.ServerKey", + **kwargs: Any + ) -> Optional["_models.ServerKey"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerKey"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerKey') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerKey') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,17 +377,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - key_name, # type: str - parameters, # type: "_models.ServerKey" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerKey"] + resource_group_name: str, + server_name: str, + key_name: str, + parameters: "_models.ServerKey", + **kwargs: Any + ) -> LROPoller["_models.ServerKey"]: """Creates or updates a server key. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -273,15 +406,18 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerKey :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. + :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. + :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 ServerKey or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerKey"] lro_delay = kwargs.pop( 'polling_interval', @@ -294,28 +430,21 @@ def begin_create_or_update( server_name=server_name, key_name=key_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerKey', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -327,41 +456,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + key_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -374,14 +495,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + key_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the server key with the given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -393,15 +515,17 @@ def begin_delete( :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -416,22 +540,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -443,4 +559,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py index faae8c67f10e2..02634786ee271 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py @@ -5,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerOperationsOperations(object): """ServerOperationsOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerOperationListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerOperationListResult"]: """Gets a list of operations performed on the server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,7 +97,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerOperationListResult or the result of cls(response) + :return: An iterator like instance of either ServerOperationListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,36 +107,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerOperationListResult', pipeline_response) + deserialized = self._deserialize("ServerOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,6 +151,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py index 3534bc825bf37..ad2c381e73846 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py @@ -5,25 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerSecurityAlertPoliciesOperations(object): """ServerSecurityAlertPoliciesOperations operations. @@ -47,14 +168,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerSecurityAlertPolicy" + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + **kwargs: Any + ) -> "_models.ServerSecurityAlertPolicy": """Get a server's security alert policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +195,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +220,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - parameters, # type: "_models.ServerSecurityAlertPolicy" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerSecurityAlertPolicy"] + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: "_models.ServerSecurityAlertPolicy", + **kwargs: Any + ) -> Optional["_models.ServerSecurityAlertPolicy"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerSecurityAlertPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerSecurityAlertPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerSecurityAlertPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,17 +269,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] - parameters, # type: "_models.ServerSecurityAlertPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerSecurityAlertPolicy"] + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: "_models.ServerSecurityAlertPolicy", + **kwargs: Any + ) -> LROPoller["_models.ServerSecurityAlertPolicy"]: """Creates or updates a threat detection policy. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -191,15 +295,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy :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. + :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 ServerSecurityAlertPolicy or the result of cls(response) + :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 ServerSecurityAlertPolicy or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicy"] lro_delay = kwargs.pop( 'polling_interval', @@ -212,28 +320,21 @@ def begin_create_or_update( server_name=server_name, security_alert_policy_name=security_alert_policy_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerSecurityAlertPolicy', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'securityAlertPolicyName': self._serialize.url("security_alert_policy_name", security_alert_policy_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -245,15 +346,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LogicalServerSecurityAlertPolicyListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.LogicalServerSecurityAlertPolicyListResult"]: """Get the server's threat detection policies. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -262,8 +364,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogicalServerSecurityAlertPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LogicalServerSecurityAlertPolicyListResult] + :return: An iterator like instance of either LogicalServerSecurityAlertPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LogicalServerSecurityAlertPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalServerSecurityAlertPolicyListResult"] @@ -271,36 +375,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LogicalServerSecurityAlertPolicyListResult', pipeline_response) + deserialized = self._deserialize("LogicalServerSecurityAlertPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -318,6 +419,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py index 38bd550fb61ec..0ec60aee1ef0e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py @@ -5,25 +5,212 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "serverTrustGroupName": _SERIALIZER.url("server_trust_group_name", server_trust_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "serverTrustGroupName": _SERIALIZER.url("server_trust_group_name", server_trust_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "serverTrustGroupName": _SERIALIZER.url("server_trust_group_name", server_trust_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_location_request( + resource_group_name: str, + location_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerTrustGroupsOperations(object): """ServerTrustGroupsOperations operations. @@ -47,14 +234,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - location_name, # type: str - server_trust_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerTrustGroup" + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + **kwargs: Any + ) -> "_models.ServerTrustGroup": """Gets a server trust group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +261,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +286,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - location_name, # type: str - server_trust_group_name, # type: str - parameters, # type: "_models.ServerTrustGroup" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerTrustGroup"] + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: "_models.ServerTrustGroup", + **kwargs: Any + ) -> Optional["_models.ServerTrustGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerTrustGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerTrustGroup') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerTrustGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +338,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - location_name, # type: str - server_trust_group_name, # type: str - parameters, # type: "_models.ServerTrustGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerTrustGroup"] + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: "_models.ServerTrustGroup", + **kwargs: Any + ) -> LROPoller["_models.ServerTrustGroup"]: """Creates or updates a server trust group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -194,15 +364,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup :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. + :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 ServerTrustGroup or the result of cls(response) + :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 ServerTrustGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerTrustGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,28 +389,21 @@ def begin_create_or_update( location_name=location_name, server_trust_group_name=server_trust_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServerTrustGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -248,41 +415,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - location_name, # type: str - server_trust_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,14 +454,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - location_name, # type: str - server_trust_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a server trust group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -314,15 +474,17 @@ def begin_delete( :type server_trust_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -337,22 +499,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -364,15 +518,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} # type: ignore + @distributed_trace def list_by_location( self, - resource_group_name, # type: str - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerTrustGroupListResult"] + resource_group_name: str, + location_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerTrustGroupListResult"]: """Lists a server trust group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -381,7 +536,8 @@ def list_by_location( :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerTrustGroupListResult or the result of cls(response) + :return: An iterator like instance of either ServerTrustGroupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -390,36 +546,33 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerTrustGroupListResult', pipeline_response) + deserialized = self._deserialize("ServerTrustGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,18 +590,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups'} # type: ignore + @distributed_trace def list_by_instance( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerTrustGroupListResult"] + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerTrustGroupListResult"]: """Gets a server trust groups by instance name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -457,7 +611,8 @@ def list_by_instance( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerTrustGroupListResult or the result of cls(response) + :return: An iterator like instance of either ServerTrustGroupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -466,36 +621,33 @@ def list_by_instance( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_instance.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerTrustGroupListResult', pipeline_response) + deserialized = self._deserialize("ServerTrustGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -513,6 +665,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_usages_operations.py index 085db0f581007..9bc593cd4977e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_usages_operations.py @@ -5,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_server_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/usages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerUsagesOperations(object): """ServerUsagesOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerUsageListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerUsageListResult"]: """Returns server usages. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -60,7 +97,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerUsageListResult or the result of cls(response) + :return: An iterator like instance of either ServerUsageListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerUsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,36 +107,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerUsageListResult', pipeline_response) + deserialized = self._deserialize("ServerUsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,6 +151,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_vulnerability_assessments_operations.py index 22ba5ffa86bbf..b780a72d531ef 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_vulnerability_assessments_operations.py @@ -5,23 +5,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServerVulnerabilityAssessmentsOperations(object): """ServerVulnerabilityAssessmentsOperations operations. @@ -45,14 +197,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerVulnerabilityAssessment" + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> "_models.ServerVulnerabilityAssessment": """Gets the server's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,28 +224,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,17 +249,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - parameters, # type: "_models.ServerVulnerabilityAssessment" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerVulnerabilityAssessment" + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: "_models.ServerVulnerabilityAssessment", + **kwargs: Any + ) -> "_models.ServerVulnerabilityAssessment": """Creates or updates the server's vulnerability assessment. Learn more about setting SQL vulnerability assessment with managed identity - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. @@ -141,33 +285,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerVulnerabilityAssessment') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerVulnerabilityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,16 +319,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - server_name, # type: str - vulnerability_assessment_name, # type: Union[str, "_models.VulnerabilityAssessmentName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + **kwargs: Any + ) -> None: """Removes the server's vulnerability assessment. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -214,26 +350,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'vulnerabilityAssessmentName': self._serialize.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,13 +374,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}'} # type: ignore + + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerVulnerabilityAssessmentListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerVulnerabilityAssessmentListResult"]: """Lists the vulnerability assessment policies associated with a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -261,8 +390,10 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerVulnerabilityAssessmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessmentListResult] + :return: An iterator like instance of either ServerVulnerabilityAssessmentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessmentListResult"] @@ -270,36 +401,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerVulnerabilityAssessmentListResult', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -317,6 +445,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_servers_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_servers_operations.py index 96a82d70fa4da..1135587a99281 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_servers_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_servers_operations.py @@ -5,25 +5,340 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_import_database_request_initial( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ServersOperations(object): """ServersOperations operations. @@ -47,13 +362,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerListResult"] + resource_group_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ServerListResult"]: """Gets a list of servers in a resource groups. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -71,37 +386,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerListResult', pipeline_response) + deserialized = self._deserialize("ServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -119,19 +430,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Server" + resource_group_name: str, + server_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Server": """Gets a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -151,29 +463,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,47 +488,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.Server" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Server"] + resource_group_name: str, + server_name: str, + parameters: "_models.Server", + **kwargs: Any + ) -> Optional["_models.Server"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Server"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Server') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Server') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,16 +538,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.Server" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Server"] + resource_group_name: str, + server_name: str, + parameters: "_models.Server", + **kwargs: Any + ) -> LROPoller["_models.Server"]: """Creates or updates a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -267,15 +561,18 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.Server :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. + :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. + :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 Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Server"] lro_delay = kwargs.pop( 'polling_interval', @@ -287,27 +584,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Server', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -319,39 +610,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -364,13 +647,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -380,15 +664,17 @@ def begin_delete( :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -402,21 +688,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -428,47 +707,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ServerUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Server"] + resource_group_name: str, + server_name: str, + parameters: "_models.ServerUpdate", + **kwargs: Any + ) -> Optional["_models.Server"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Server"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ServerUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -484,16 +753,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ServerUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Server"] + resource_group_name: str, + server_name: str, + parameters: "_models.ServerUpdate", + **kwargs: Any + ) -> LROPoller["_models.Server"]: """Updates a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -505,15 +776,18 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.ServerUpdate :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. + :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. + :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 Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Server"] lro_delay = kwargs.pop( 'polling_interval', @@ -525,27 +799,21 @@ def begin_update( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Server', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -557,14 +825,15 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}'} # type: ignore + @distributed_trace def list( self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerListResult"] + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ServerListResult"]: """Gets a list of all servers in the subscription. :param expand: The child resources to include in the response. @@ -579,36 +848,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServerListResult', pipeline_response) + deserialized = self._deserialize("ServerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -626,6 +890,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -633,43 +898,32 @@ def get_next(next_link=None): def _import_database_initial( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ImportNewDatabaseDefinition" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ImportExportOperationResult"] + resource_group_name: str, + server_name: str, + parameters: "_models.ImportNewDatabaseDefinition", + **kwargs: Any + ) -> Optional["_models.ImportExportOperationResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._import_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ImportNewDatabaseDefinition') + + request = build_import_database_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._import_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ImportNewDatabaseDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -685,16 +939,18 @@ def _import_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _import_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import'} # type: ignore + + @distributed_trace def begin_import_database( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.ImportNewDatabaseDefinition" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ImportExportOperationResult"] + resource_group_name: str, + server_name: str, + parameters: "_models.ImportNewDatabaseDefinition", + **kwargs: Any + ) -> LROPoller["_models.ImportExportOperationResult"]: """Imports a bacpac into a new database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -706,15 +962,19 @@ def begin_import_database( :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition :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. + :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 ImportExportOperationResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ImportExportOperationResult or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -726,27 +986,21 @@ def begin_import_database( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -758,14 +1012,15 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_import_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import'} # type: ignore + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.CheckNameAvailabilityRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResponse" + parameters: "_models.CheckNameAvailabilityRequest", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResponse": """Determines whether a resource can be created with the specified name. :param parameters: The name availability request parameters. @@ -780,30 +1035,20 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailabilityRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -817,4 +1062,6 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py index e002323d24d47..d76bd4a220b6b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_get_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + service_objective_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "serviceObjectiveName": _SERIALIZER.url("service_objective_name", service_objective_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServiceObjectivesOperations(object): """ServiceObjectivesOperations operations. @@ -45,14 +119,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - service_objective_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceObjective" + resource_group_name: str, + server_name: str, + service_objective_name: str, + **kwargs: Any + ) -> "_models.ServiceObjective": """Gets a database service objective. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -72,28 +146,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'serviceObjectiveName': self._serialize.url("service_objective_name", service_objective_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + service_objective_name=service_objective_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,15 +171,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}'} # type: ignore + + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServiceObjectiveListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServiceObjectiveListResult"]: """Returns database service objectives. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -124,7 +190,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceObjectiveListResult or the result of cls(response) + :return: An iterator like instance of either ServiceObjectiveListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServiceObjectiveListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -133,36 +200,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServiceObjectiveListResult', pipeline_response) + deserialized = self._deserialize("ServiceObjectiveListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,6 +244,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_agent_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_agent_operations.py index f9bd04befb0de..afeb1db8f29d6 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_agent_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_agent_operations.py @@ -5,22 +5,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class SqlAgentOperations(object): """SqlAgentOperations operations. @@ -44,13 +126,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - managed_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlAgentConfiguration" + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> "_models.SqlAgentConfiguration": """Gets current instance sql agent configuration. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -68,27 +150,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,16 +174,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - managed_instance_name, # type: str - parameters, # type: "_models.SqlAgentConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlAgentConfiguration" + resource_group_name: str, + managed_instance_name: str, + parameters: "_models.SqlAgentConfiguration", + **kwargs: Any + ) -> "_models.SqlAgentConfiguration": """Puts new sql agent configuration to instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -131,32 +205,22 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlAgentConfiguration') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SqlAgentConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,4 +234,6 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py index f0850a84fcbca..f5a0a01d5c104 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py @@ -5,23 +5,93 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_location_request( + location_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + location_name: str, + usage_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "usageName": _SERIALIZER.url("usage_name", usage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SubscriptionUsagesOperations(object): """SubscriptionUsagesOperations operations. @@ -45,18 +115,19 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_location( self, - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SubscriptionUsageListResult"] + location_name: str, + **kwargs: Any + ) -> Iterable["_models.SubscriptionUsageListResult"]: """Gets all subscription usage metrics in a given location. :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionUsageListResult or the result of cls(response) + :return: An iterator like instance of either SubscriptionUsageListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SubscriptionUsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -65,35 +136,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionUsageListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionUsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,18 +178,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages'} # type: ignore + @distributed_trace def get( self, - location_name, # type: str - usage_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionUsage" + location_name: str, + usage_name: str, + **kwargs: Any + ) -> "_models.SubscriptionUsage": """Gets a subscription usage metric. :param location_name: The name of the region where the resource is located. @@ -139,27 +207,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'usageName': self._serialize.url("usage_name", usage_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + usage_name=usage_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,4 +231,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_agents_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_agents_operations.py index 356b243e8a867..3d214388d5f11 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_agents_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_agents_operations.py @@ -5,25 +5,251 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + sync_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + sync_agent_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + sync_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_key_request( + resource_group_name: str, + server_name: str, + sync_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/generateKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_linked_databases_request( + resource_group_name: str, + server_name: str, + sync_agent_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/linkedDatabases') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SyncAgentsOperations(object): """SyncAgentsOperations operations. @@ -47,14 +273,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - sync_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SyncAgent" + resource_group_name: str, + server_name: str, + sync_agent_name: str, + **kwargs: Any + ) -> "_models.SyncAgent": """Gets a sync agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +300,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +325,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - sync_agent_name, # type: str - parameters, # type: "_models.SyncAgent" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SyncAgent"] + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: "_models.SyncAgent", + **kwargs: Any + ) -> Optional["_models.SyncAgent"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SyncAgent"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SyncAgent') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncAgent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +377,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - sync_agent_name, # type: str - parameters, # type: "_models.SyncAgent" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SyncAgent"] + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: "_models.SyncAgent", + **kwargs: Any + ) -> LROPoller["_models.SyncAgent"]: """Creates or updates a sync agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -194,15 +403,18 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.SyncAgent :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. + :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. + :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 SyncAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,28 +427,21 @@ def begin_create_or_update( server_name=server_name, sync_agent_name=sync_agent_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -248,41 +453,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - sync_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + sync_agent_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,14 +492,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - sync_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + sync_agent_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a sync agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -314,15 +512,17 @@ def begin_delete( :type sync_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -337,22 +537,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -364,15 +556,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncAgentListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncAgentListResult"]: """Lists sync agents in a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -390,36 +583,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncAgentListResult', pipeline_response) + deserialized = self._deserialize("SyncAgentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,19 +627,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents'} # type: ignore + @distributed_trace def generate_key( self, - resource_group_name, # type: str - server_name, # type: str - sync_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SyncAgentKeyProperties" + resource_group_name: str, + server_name: str, + sync_agent_name: str, + **kwargs: Any + ) -> "_models.SyncAgentKeyProperties": """Generates a sync agent key. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -469,28 +660,18 @@ def generate_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_key_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.generate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -504,16 +685,18 @@ def generate_key( return cls(pipeline_response, deserialized, {}) return deserialized + generate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/generateKey'} # type: ignore + + @distributed_trace def list_linked_databases( self, - resource_group_name, # type: str - server_name, # type: str - sync_agent_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncAgentLinkedDatabaseListResult"] + resource_group_name: str, + server_name: str, + sync_agent_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncAgentLinkedDatabaseListResult"]: """Lists databases linked to a sync agent. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -524,7 +707,8 @@ def list_linked_databases( :param sync_agent_name: The name of the sync agent. :type sync_agent_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncAgentLinkedDatabaseListResult or the result of cls(response) + :return: An iterator like instance of either SyncAgentLinkedDatabaseListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncAgentLinkedDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -533,37 +717,35 @@ def list_linked_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_linked_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'syncAgentName': self._serialize.url("sync_agent_name", sync_agent_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_linked_databases_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=self.list_linked_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_linked_databases_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncAgentLinkedDatabaseListResult', pipeline_response) + deserialized = self._deserialize("SyncAgentLinkedDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -581,6 +763,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py index e07c23af964b4..33de92e36e7dd 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py @@ -5,25 +5,453 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_sync_database_ids_request( + location_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_refresh_hub_schema_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_hub_schemas_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_logs_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + *, + start_time: str, + end_time: str, + type: Union[str, "_models.SyncGroupsType"], + continuation_token_parameter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + query_parameters['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + query_parameters['type'] = _SERIALIZER.query("type", type, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = _SERIALIZER.query("continuation_token_parameter", continuation_token_parameter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_cancel_sync_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_trigger_sync_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SyncGroupsOperations(object): """SyncGroupsOperations operations. @@ -47,18 +475,19 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_sync_database_ids( self, - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncDatabaseIdListResult"] + location_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncDatabaseIdListResult"]: """Gets a collection of sync database ids. :param location_name: The name of the region where the resource is located. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncDatabaseIdListResult or the result of cls(response) + :return: An iterator like instance of either SyncDatabaseIdListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncDatabaseIdListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -67,35 +496,31 @@ def list_sync_database_ids( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sync_database_ids.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sync_database_ids_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_sync_database_ids.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sync_database_ids_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncDatabaseIdListResult', pipeline_response) + deserialized = self._deserialize("SyncDatabaseIdListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,6 +538,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -120,39 +546,30 @@ def get_next(next_link=None): def _refresh_hub_schema_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._refresh_hub_schema_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_refresh_hub_schema_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self._refresh_hub_schema_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,15 +582,16 @@ def _refresh_hub_schema_initial( _refresh_hub_schema_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema'} # type: ignore + + @distributed_trace def begin_refresh_hub_schema( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Refreshes a hub database schema. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -187,15 +605,17 @@ def begin_refresh_hub_schema( :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -211,23 +631,14 @@ def begin_refresh_hub_schema( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -239,17 +650,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_refresh_hub_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema'} # type: ignore + @distributed_trace def list_hub_schemas( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncFullSchemaPropertiesListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncFullSchemaPropertiesListResult"]: """Gets a collection of hub database schemas. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -262,7 +674,8 @@ def list_hub_schemas( :param sync_group_name: The name of the sync group. :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result of cls(response) + :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result + of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaPropertiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -271,38 +684,37 @@ def list_hub_schemas( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_hub_schemas.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_hub_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_hub_schemas.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_hub_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncFullSchemaPropertiesListResult', pipeline_response) + deserialized = self._deserialize("SyncFullSchemaPropertiesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -320,24 +732,25 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_hub_schemas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas'} # type: ignore + @distributed_trace def list_logs( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - start_time, # type: str - end_time, # type: str - type, # type: Union[str, "_models.Enum60"] - continuation_token_parameter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncGroupLogListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + start_time: str, + end_time: str, + type: Union[str, "_models.SyncGroupsType"], + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SyncGroupLogListResult"]: """Gets a collection of sync group logs. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -354,11 +767,12 @@ def list_logs( :param end_time: Get logs generated before this time. :type end_time: str :param type: The types of logs to retrieve. - :type type: str or ~azure.mgmt.sql.models.Enum60 + :type type: str or ~azure.mgmt.sql.models.SyncGroupsType :param continuation_token_parameter: The continuation token for this operation. :type continuation_token_parameter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncGroupLogListResult or the result of cls(response) + :return: An iterator like instance of either SyncGroupLogListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncGroupLogListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -367,43 +781,45 @@ def list_logs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_logs.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - query_parameters['type'] = self._serialize.query("type", type, 'str') - if continuation_token_parameter is not None: - query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_logs_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + type=type, + continuation_token_parameter=continuation_token_parameter, + template_url=self.list_logs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_logs_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + type=type, + continuation_token_parameter=continuation_token_parameter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncGroupLogListResult', pipeline_response) + deserialized = self._deserialize("SyncGroupLogListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -421,20 +837,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs'} # type: ignore + @distributed_trace def cancel_sync( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> None: """Cancels a sync group synchronization. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -456,27 +873,19 @@ def cancel_sync( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.cancel_sync.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_sync_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_sync.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -489,15 +898,16 @@ def cancel_sync( cancel_sync.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync'} # type: ignore + + @distributed_trace def trigger_sync( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> None: """Triggers a sync group synchronization. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -519,27 +929,19 @@ def trigger_sync( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self.trigger_sync.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_trigger_sync_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.trigger_sync.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -552,15 +954,16 @@ def trigger_sync( trigger_sync.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SyncGroup" + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> "_models.SyncGroup": """Gets a sync group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -582,29 +985,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -618,51 +1011,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - parameters, # type: "_models.SyncGroup" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SyncGroup"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: "_models.SyncGroup", + **kwargs: Any + ) -> Optional["_models.SyncGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SyncGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SyncGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -681,18 +1065,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - parameters, # type: "_models.SyncGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SyncGroup"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: "_models.SyncGroup", + **kwargs: Any + ) -> LROPoller["_models.SyncGroup"]: """Creates or updates a sync group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -708,15 +1094,18 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.SyncGroup :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. + :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. + :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 SyncGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -730,29 +1119,21 @@ def begin_create_or_update( database_name=database_name, sync_group_name=sync_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -764,43 +1145,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -813,15 +1186,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a sync group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -835,15 +1209,17 @@ def begin_delete( :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -859,23 +1235,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -887,51 +1254,41 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - parameters, # type: "_models.SyncGroup" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SyncGroup"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: "_models.SyncGroup", + **kwargs: Any + ) -> Optional["_models.SyncGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SyncGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SyncGroup') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncGroup') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -947,18 +1304,20 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - parameters, # type: "_models.SyncGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SyncGroup"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: "_models.SyncGroup", + **kwargs: Any + ) -> LROPoller["_models.SyncGroup"]: """Updates a sync group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -974,15 +1333,18 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.SyncGroup :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. + :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. + :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 SyncGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -996,29 +1358,21 @@ def begin_update( database_name=database_name, sync_group_name=sync_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1030,16 +1384,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncGroupListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncGroupListResult"]: """Lists sync groups under a hub database. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1059,37 +1414,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncGroupListResult', pipeline_response) + deserialized = self._deserialize("SyncGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1107,6 +1460,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py index dc1f1bab5a64f..048769a92d982 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py @@ -5,25 +5,319 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_sync_group_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_member_schemas_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_refresh_member_schema_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) class SyncMembersOperations(object): """SyncMembersOperations operations. @@ -47,16 +341,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SyncMember" + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> "_models.SyncMember": """Gets a sync member. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -80,30 +374,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -117,53 +401,44 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - parameters, # type: "_models.SyncMember" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SyncMember"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: "_models.SyncMember", + **kwargs: Any + ) -> Optional["_models.SyncMember"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SyncMember"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SyncMember') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncMember') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,19 +457,21 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - parameters, # type: "_models.SyncMember" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SyncMember"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: "_models.SyncMember", + **kwargs: Any + ) -> LROPoller["_models.SyncMember"]: """Creates or updates a sync member. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -212,15 +489,18 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.SyncMember :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. + :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. + :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 SyncMember or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncMember"] lro_delay = kwargs.pop( 'polling_interval', @@ -235,30 +515,21 @@ def begin_create_or_update( sync_group_name=sync_group_name, sync_member_name=sync_member_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncMember', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -270,45 +541,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -321,16 +584,17 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a sync member. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -346,15 +610,17 @@ def begin_delete( :type sync_member_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -371,24 +637,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -400,53 +656,43 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - parameters, # type: "_models.SyncMember" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SyncMember"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: "_models.SyncMember", + **kwargs: Any + ) -> Optional["_models.SyncMember"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SyncMember"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SyncMember') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncMember') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -462,19 +708,21 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - parameters, # type: "_models.SyncMember" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SyncMember"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: "_models.SyncMember", + **kwargs: Any + ) -> LROPoller["_models.SyncMember"]: """Updates an existing sync member. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -492,15 +740,18 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.SyncMember :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. + :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. + :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 SyncMember or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SyncMember"] lro_delay = kwargs.pop( 'polling_interval', @@ -515,30 +766,21 @@ def begin_update( sync_group_name=sync_group_name, sync_member_name=sync_member_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SyncMember', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -550,17 +792,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}'} # type: ignore + @distributed_trace def list_by_sync_group( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncMemberListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncMemberListResult"]: """Lists sync members in the given sync group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -573,7 +816,8 @@ def list_by_sync_group( :param sync_group_name: The name of the sync group. :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncMemberListResult or the result of cls(response) + :return: An iterator like instance of either SyncMemberListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncMemberListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -582,38 +826,37 @@ def list_by_sync_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sync_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_sync_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncMemberListResult', pipeline_response) + deserialized = self._deserialize("SyncMemberListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -631,21 +874,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_sync_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers'} # type: ignore + @distributed_trace def list_member_schemas( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncFullSchemaPropertiesListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncFullSchemaPropertiesListResult"]: """Gets a sync member database schema. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -660,7 +904,8 @@ def list_member_schemas( :param sync_member_name: The name of the sync member. :type sync_member_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result of cls(response) + :return: An iterator like instance of either SyncFullSchemaPropertiesListResult or the result + of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaPropertiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -669,39 +914,39 @@ def list_member_schemas( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_member_schemas.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_member_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self.list_member_schemas.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_member_schemas_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SyncFullSchemaPropertiesListResult', pipeline_response) + deserialized = self._deserialize("SyncFullSchemaPropertiesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +964,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -726,41 +972,32 @@ def get_next(next_link=None): def _refresh_member_schema_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._refresh_member_schema_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_refresh_member_schema_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + template_url=self._refresh_member_schema_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -773,16 +1010,17 @@ def _refresh_member_schema_initial( _refresh_member_schema_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema'} # type: ignore + + @distributed_trace def begin_refresh_member_schema( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - sync_group_name, # type: str - sync_member_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Refreshes a sync member database schema. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -798,15 +1036,17 @@ def begin_refresh_member_schema( :type sync_member_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -823,24 +1063,14 @@ def begin_refresh_member_schema( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -852,4 +1082,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_refresh_member_schema.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py index 8a7021c831b65..7447fd56e1ffa 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py @@ -5,24 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class TdeCertificatesOperations(object): """TdeCertificatesOperations operations. @@ -48,41 +93,32 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.TdeCertificate" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + parameters: "_models.TdeCertificate", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'TdeCertificate') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TdeCertificate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,14 +131,15 @@ def _create_initial( _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - server_name, # type: str - parameters, # type: "_models.TdeCertificate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + parameters: "_models.TdeCertificate", + **kwargs: Any + ) -> LROPoller[None]: """Creates a TDE certificate for a given server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -114,15 +151,18 @@ def begin_create( :type parameters: ~azure.mgmt.sql.models.TdeCertificate :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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -134,24 +174,18 @@ def begin_create( resource_group_name=resource_group_name, server_name=server_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -163,4 +197,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py index 8fccaef680680..cb17ae5d93493 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py @@ -5,23 +5,93 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_location_request( + location_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + location_name: str, + time_zone_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones/{timeZoneId}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "timeZoneId": _SERIALIZER.url("time_zone_id", time_zone_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class TimeZonesOperations(object): """TimeZonesOperations operations. @@ -45,12 +115,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_location( self, - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TimeZoneListResult"] + location_name: str, + **kwargs: Any + ) -> Iterable["_models.TimeZoneListResult"]: """Gets a list of managed instance time zones by location. :param location_name: @@ -65,35 +135,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TimeZoneListResult', pipeline_response) + deserialized = self._deserialize("TimeZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,18 +177,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones'} # type: ignore + @distributed_trace def get( self, - location_name, # type: str - time_zone_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TimeZone" + location_name: str, + time_zone_id: str, + **kwargs: Any + ) -> "_models.TimeZone": """Gets a managed instance time zone. :param location_name: @@ -139,27 +206,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'timeZoneId': self._serialize.url("time_zone_id", time_zone_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + time_zone_id=time_zone_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,4 +230,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones/{timeZoneId}'} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py index ff414142d1c40..bd05dae14ae24 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py @@ -5,23 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "tdeName": _SERIALIZER.url("tde_name", tde_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "tdeName": _SERIALIZER.url("tde_name", tde_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class TransparentDataEncryptionsOperations(object): """TransparentDataEncryptionsOperations operations. @@ -45,15 +172,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - tde_name, # type: Union[str, "_models.TransparentDataEncryptionName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.LogicalDatabaseTransparentDataEncryption" + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + **kwargs: Any + ) -> "_models.LogicalDatabaseTransparentDataEncryption": """Gets a logical database's transparent data encryption. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -76,29 +203,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,18 +229,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - tde_name, # type: Union[str, "_models.TransparentDataEncryptionName"] - parameters, # type: "_models.LogicalDatabaseTransparentDataEncryption" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.LogicalDatabaseTransparentDataEncryption"] + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + parameters: "_models.LogicalDatabaseTransparentDataEncryption", + **kwargs: Any + ) -> Optional["_models.LogicalDatabaseTransparentDataEncryption"]: """Updates a logical database's transparent data encryption configuration. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -148,34 +267,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'LogicalDatabaseTransparentDataEncryption') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogicalDatabaseTransparentDataEncryption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -194,16 +303,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LogicalDatabaseTransparentDataEncryptionListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.LogicalDatabaseTransparentDataEncryptionListResult"]: """Gets a list of the logical database's transparent data encryption. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -215,8 +326,10 @@ def list_by_database( encryption is defined. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryptionListResult] + :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryptionListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalDatabaseTransparentDataEncryptionListResult"] @@ -224,37 +337,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryptionListResult', pipeline_response) + deserialized = self._deserialize("LogicalDatabaseTransparentDataEncryptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -272,6 +383,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_usages_operations.py index 0ef3571ae7cb9..1fe5328445387 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_usages_operations.py @@ -5,23 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_pool_request( + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + *, + expand_children: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-02-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand_children is not None: + query_parameters['expandChildren'] = _SERIALIZER.query("expand_children", expand_children, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class UsagesOperations(object): """UsagesOperations operations. @@ -45,14 +86,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_instance_pool( self, - resource_group_name, # type: str - instance_pool_name, # type: str - expand_children=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsageListResult"] + resource_group_name: str, + instance_pool_name: str, + expand_children: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.UsageListResult"]: """Gets all instance pool usage metrics. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -73,38 +114,35 @@ def list_by_instance_pool( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_instance_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'instancePoolName': self._serialize.url("instance_pool_name", instance_pool_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_children is not None: - query_parameters['expandChildren'] = self._serialize.query("expand_children", expand_children, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand_children=expand_children, + template_url=self.list_by_instance_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand_children=expand_children, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UsageListResult', pipeline_response) + deserialized = self._deserialize("UsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,6 +160,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py index 7bcfffbc81f25..5ebabffc06c96 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py @@ -5,25 +5,235 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_update_dns_servers_request( + resource_group_name: str, + virtual_cluster_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}/updateManagedInstanceDnsServers') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + virtual_cluster_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + virtual_cluster_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + virtual_cluster_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class VirtualClustersOperations(object): """VirtualClustersOperations operations. @@ -47,13 +257,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def update_dns_servers( self, - resource_group_name, # type: str - virtual_cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateManagedInstanceDnsServersOperation" + resource_group_name: str, + virtual_cluster_name: str, + **kwargs: Any + ) -> "_models.UpdateManagedInstanceDnsServersOperation": """Synchronizes the DNS server settings used by the managed instances inside the given virtual cluster. @@ -72,27 +282,17 @@ def update_dns_servers( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.update_dns_servers.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_update_dns_servers_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + template_url=self.update_dns_servers.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,17 +306,20 @@ def update_dns_servers( return cls(pipeline_response, deserialized, {}) return deserialized + update_dns_servers.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}/updateManagedInstanceDnsServers'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualClusterListResult"] + **kwargs: Any + ) -> Iterable["_models.VirtualClusterListResult"]: """Gets a list of all virtualClusters in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualClusterListResult or the result of cls(response) + :return: An iterator like instance of either VirtualClusterListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -125,34 +328,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualClusterListResult', pipeline_response) + deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -170,24 +368,26 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualClusterListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualClusterListResult"]: """Gets a list of virtual clusters in a resource group. :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualClusterListResult or the result of cls(response) + :return: An iterator like instance of either VirtualClusterListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -196,35 +396,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualClusterListResult', pipeline_response) + deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -242,18 +438,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - virtual_cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualCluster" + resource_group_name: str, + virtual_cluster_name: str, + **kwargs: Any + ) -> "_models.VirtualCluster": """Gets a virtual cluster. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -271,27 +468,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -305,39 +492,32 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - virtual_cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_cluster_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -350,13 +530,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - virtual_cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_cluster_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a virtual cluster. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -366,15 +547,17 @@ def begin_delete( :type virtual_cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -388,21 +571,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -414,47 +590,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - virtual_cluster_name, # type: str - parameters, # type: "_models.VirtualClusterUpdate" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.VirtualCluster"] + resource_group_name: str, + virtual_cluster_name: str, + parameters: "_models.VirtualClusterUpdate", + **kwargs: Any + ) -> Optional["_models.VirtualCluster"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualCluster"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'VirtualClusterUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VirtualClusterUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -470,16 +636,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - virtual_cluster_name, # type: str - parameters, # type: "_models.VirtualClusterUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VirtualCluster"] + resource_group_name: str, + virtual_cluster_name: str, + parameters: "_models.VirtualClusterUpdate", + **kwargs: Any + ) -> LROPoller["_models.VirtualCluster"]: """Updates a virtual cluster. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -491,15 +659,19 @@ def begin_update( :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate :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. + :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 VirtualCluster or the result of cls(response) + :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 VirtualCluster or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualCluster"] lro_delay = kwargs.pop( 'polling_interval', @@ -511,27 +683,21 @@ def begin_update( resource_group_name=resource_group_name, virtual_cluster_name=virtual_cluster_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualCluster', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualClusterName': self._serialize.url("virtual_cluster_name", virtual_cluster_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -543,4 +709,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py index 296d69898f763..5b08479d2b4ef 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py @@ -5,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class VirtualNetworkRulesOperations(object): """VirtualNetworkRulesOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - virtual_network_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetworkRule" + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + **kwargs: Any + ) -> "_models.VirtualNetworkRule": """Gets a virtual network rule. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - virtual_network_rule_name, # type: str - parameters, # type: "_models.VirtualNetworkRule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.VirtualNetworkRule"] + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: "_models.VirtualNetworkRule", + **kwargs: Any + ) -> Optional["_models.VirtualNetworkRule"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkRule"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'VirtualNetworkRule') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VirtualNetworkRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,17 +303,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - virtual_network_rule_name, # type: str - parameters, # type: "_models.VirtualNetworkRule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VirtualNetworkRule"] + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: "_models.VirtualNetworkRule", + **kwargs: Any + ) -> LROPoller["_models.VirtualNetworkRule"]: """Creates or updates an existing virtual network rule. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -194,15 +329,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule :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. + :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 VirtualNetworkRule or the result of cls(response) + :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 VirtualNetworkRule or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRule"] lro_delay = kwargs.pop( 'polling_interval', @@ -215,28 +354,21 @@ def begin_create_or_update( server_name=server_name, virtual_network_rule_name=virtual_network_rule_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -248,41 +380,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - virtual_network_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,14 +419,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - virtual_network_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the virtual network rule with the given name. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -314,15 +439,17 @@ def begin_delete( :type virtual_network_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -337,22 +464,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -364,15 +483,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'} # type: ignore + @distributed_trace def list_by_server( self, - resource_group_name, # type: str - server_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualNetworkRuleListResult"] + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworkRuleListResult"]: """Gets a list of virtual network rules in a server. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -381,7 +501,8 @@ def list_by_server( :param server_name: The name of the server. :type server_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of cls(response) + :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualNetworkRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -390,36 +511,33 @@ def list_by_server( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_server.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworkRuleListResult', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,6 +555,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py index d8295e40f1bd8..04c4cfa21acb9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py @@ -5,25 +5,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_workload_group_request( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WorkloadClassifiersOperations(object): """WorkloadClassifiersOperations operations. @@ -47,16 +215,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - workload_classifier_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadClassifier" + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> "_models.WorkloadClassifier": """Gets a workload classifier. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -81,30 +249,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -118,53 +276,44 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - workload_classifier_name, # type: str - parameters, # type: "_models.WorkloadClassifier" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadClassifier"] + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: "_models.WorkloadClassifier", + **kwargs: Any + ) -> Optional["_models.WorkloadClassifier"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadClassifier"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'WorkloadClassifier') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WorkloadClassifier') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,19 +332,21 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - workload_classifier_name, # type: str - parameters, # type: "_models.WorkloadClassifier" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadClassifier"] + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: "_models.WorkloadClassifier", + **kwargs: Any + ) -> LROPoller["_models.WorkloadClassifier"]: """Creates or updates a workload classifier. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -214,15 +365,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier :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. + :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 WorkloadClassifier or the result of cls(response) + :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 WorkloadClassifier or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifier"] lro_delay = kwargs.pop( 'polling_interval', @@ -237,30 +392,21 @@ def begin_create_or_update( workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WorkloadClassifier', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -272,45 +418,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - workload_classifier_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -323,16 +461,17 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - workload_classifier_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a workload classifier. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -349,15 +488,17 @@ def begin_delete( :type workload_classifier_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -374,24 +515,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -403,17 +534,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} # type: ignore + @distributed_trace def list_by_workload_group( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadClassifierListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkloadClassifierListResult"]: """Gets the list of workload classifiers for a workload group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -427,7 +559,8 @@ def list_by_workload_group( classifiers from. :type workload_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadClassifierListResult or the result of cls(response) + :return: An iterator like instance of either WorkloadClassifierListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadClassifierListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -436,38 +569,37 @@ def list_by_workload_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_workload_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_workload_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_workload_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_workload_group_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkloadClassifierListResult', pipeline_response) + deserialized = self._deserialize("WorkloadClassifierListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -485,6 +617,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py index 3a0c0c3b70739..f2df4969b9384 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py @@ -5,25 +5,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_database_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WorkloadGroupsOperations(object): """WorkloadGroupsOperations operations. @@ -47,15 +207,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadGroup" + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + **kwargs: Any + ) -> "_models.WorkloadGroup": """Gets a workload group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -77,29 +237,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,51 +263,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - parameters, # type: "_models.WorkloadGroup" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadGroup"] + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: "_models.WorkloadGroup", + **kwargs: Any + ) -> Optional["_models.WorkloadGroup"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadGroup"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'WorkloadGroup') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WorkloadGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,18 +317,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - parameters, # type: "_models.WorkloadGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadGroup"] + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: "_models.WorkloadGroup", + **kwargs: Any + ) -> LROPoller["_models.WorkloadGroup"]: """Creates or updates a workload group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -203,15 +346,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sql.models.WorkloadGroup :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. + :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 WorkloadGroup or the result of cls(response) + :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 WorkloadGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -225,29 +372,21 @@ def begin_create_or_update( database_name=database_name, workload_group_name=workload_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WorkloadGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -259,43 +398,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,15 +439,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - workload_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a workload group. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -330,15 +462,17 @@ def begin_delete( :type workload_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -354,23 +488,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -382,16 +507,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} # type: ignore + @distributed_trace def list_by_database( self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadGroupListResult"] + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkloadGroupListResult"]: """Gets the list of workload groups. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -402,7 +528,8 @@ def list_by_database( :param database_name: The name of the database. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadGroupListResult or the result of cls(response) + :return: An iterator like instance of either WorkloadGroupListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -411,37 +538,35 @@ def list_by_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkloadGroupListResult', pipeline_response) + deserialized = self._deserialize("WorkloadGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -459,6 +584,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data )